Standard JS code conversion + fixes
This commit is contained in:
		| @@ -1,102 +1,96 @@ | ||||
|  | ||||
| if($('#page-type-admin-profile').length) { | ||||
| if ($('#page-type-admin-profile').length) { | ||||
|   let vueProfile = new Vue({ | ||||
|     el: '#page-type-admin-profile', | ||||
|     data: { | ||||
|       password: '********', | ||||
|       passwordVerify: '********', | ||||
|       name: '' | ||||
|     }, | ||||
|     methods: { | ||||
|       saveUser: (ev) => { | ||||
|         if (vueProfile.password !== vueProfile.passwordVerify) { | ||||
|           alerts.pushError('Error', "Passwords don't match!") | ||||
|           return | ||||
|         } | ||||
|         $.post(window.location.href, { | ||||
|           password: vueProfile.password, | ||||
|           name: vueProfile.name | ||||
|         }).done((resp) => { | ||||
|           alerts.pushSuccess('Saved successfully', 'Changes have been applied.') | ||||
|         }).fail((jqXHR, txtStatus, resp) => { | ||||
|           alerts.pushError('Error', resp) | ||||
|         }) | ||||
|       } | ||||
|     }, | ||||
|     created: function () { | ||||
|       this.name = usrDataName | ||||
|     } | ||||
|   }) | ||||
| } else if ($('#page-type-admin-users').length) { | ||||
|  | ||||
| 	let vueProfile = new Vue({ | ||||
| 		el: '#page-type-admin-profile', | ||||
| 		data: { | ||||
| 			password: '********', | ||||
| 			passwordVerify: '********', | ||||
| 			name: '' | ||||
| 		}, | ||||
| 		methods: { | ||||
| 			saveUser: (ev) => { | ||||
| 				if(vueProfile.password !== vueProfile.passwordVerify) { | ||||
| 					alerts.pushError('Error', "Passwords don't match!"); | ||||
| 					return; | ||||
| 				} | ||||
| 				$.post(window.location.href, { | ||||
| 					password: vueProfile.password, | ||||
| 					name: vueProfile.name | ||||
| 				}).done((resp) => { | ||||
| 					alerts.pushSuccess('Saved successfully', 'Changes have been applied.'); | ||||
| 				}).fail((jqXHR, txtStatus, resp) => { | ||||
| 					alerts.pushError('Error', resp); | ||||
| 				}) | ||||
| 			} | ||||
| 		}, | ||||
| 		created: function() { | ||||
| 			this.name = usrDataName; | ||||
| 		} | ||||
| 	}); | ||||
| 	// =include ../modals/admin-users-create.js | ||||
|  | ||||
| } else if($('#page-type-admin-users').length) { | ||||
| } else if ($('#page-type-admin-users-edit').length) { | ||||
|   let vueEditUser = new Vue({ | ||||
|     el: '#page-type-admin-users-edit', | ||||
|     data: { | ||||
|       id: '', | ||||
|       email: '', | ||||
|       password: '********', | ||||
|       name: '', | ||||
|       rights: [], | ||||
|       roleoverride: 'none' | ||||
|     }, | ||||
|     methods: { | ||||
|       addRightsRow: (ev) => { | ||||
|         vueEditUser.rights.push({ | ||||
|           role: 'write', | ||||
|           path: '/', | ||||
|           exact: false, | ||||
|           deny: false | ||||
|         }) | ||||
|       }, | ||||
|       removeRightsRow: (idx) => { | ||||
|         _.pullAt(vueEditUser.rights, idx) | ||||
|         vueEditUser.$forceUpdate() | ||||
|       }, | ||||
|       saveUser: (ev) => { | ||||
|         let formattedRights = _.cloneDeep(vueEditUser.rights) | ||||
|         switch (vueEditUser.roleoverride) { | ||||
|           case 'admin': | ||||
|             formattedRights.push({ | ||||
|               role: 'admin', | ||||
|               path: '/', | ||||
|               exact: false, | ||||
|               deny: false | ||||
|             }) | ||||
|             break | ||||
|         } | ||||
|         $.post(window.location.href, { | ||||
|           password: vueEditUser.password, | ||||
|           name: vueEditUser.name, | ||||
|           rights: JSON.stringify(formattedRights) | ||||
|         }).done((resp) => { | ||||
|           alerts.pushSuccess('Saved successfully', 'Changes have been applied.') | ||||
|         }).fail((jqXHR, txtStatus, resp) => { | ||||
|           alerts.pushError('Error', resp) | ||||
|         }) | ||||
|       } | ||||
|     }, | ||||
|     created: function () { | ||||
|       this.id = usrData._id | ||||
|       this.email = usrData.email | ||||
|       this.name = usrData.name | ||||
|  | ||||
| 	//=include ../modals/admin-users-create.js | ||||
|       if (_.find(usrData.rights, { role: 'admin' })) { | ||||
|         this.rights = _.reject(usrData.rights, ['role', 'admin']) | ||||
|         this.roleoverride = 'admin' | ||||
|       } else { | ||||
|         this.rights = usrData.rights | ||||
|       } | ||||
|     } | ||||
|   }) | ||||
|  | ||||
| } else if($('#page-type-admin-users-edit').length) { | ||||
|  | ||||
| 	let vueEditUser = new Vue({ | ||||
| 		el: '#page-type-admin-users-edit', | ||||
| 		data: { | ||||
| 			id: '', | ||||
| 			email: '', | ||||
| 			password: '********', | ||||
| 			name: '', | ||||
| 			rights: [], | ||||
| 			roleoverride: 'none' | ||||
| 		}, | ||||
| 		methods: { | ||||
| 			addRightsRow: (ev) => { | ||||
| 				vueEditUser.rights.push({ | ||||
| 					role: 'write', | ||||
| 					path: '/', | ||||
| 					exact: false, | ||||
| 					deny: false | ||||
| 				}); | ||||
| 			}, | ||||
| 			removeRightsRow: (idx) => { | ||||
| 				_.pullAt(vueEditUser.rights, idx) | ||||
| 				vueEditUser.$forceUpdate() | ||||
| 			}, | ||||
| 			saveUser: (ev) => { | ||||
| 				let formattedRights = _.cloneDeep(vueEditUser.rights) | ||||
| 				switch(vueEditUser.roleoverride) { | ||||
| 					case 'admin': | ||||
| 						formattedRights.push({ | ||||
| 							role: 'admin', | ||||
| 							path: '/', | ||||
| 							exact: false, | ||||
| 							deny: false | ||||
| 						}) | ||||
| 					break; | ||||
| 				} | ||||
| 				$.post(window.location.href, { | ||||
| 					password: vueEditUser.password, | ||||
| 					name: vueEditUser.name, | ||||
| 					rights: JSON.stringify(formattedRights) | ||||
| 				}).done((resp) => { | ||||
| 					alerts.pushSuccess('Saved successfully', 'Changes have been applied.'); | ||||
| 				}).fail((jqXHR, txtStatus, resp) => { | ||||
| 					alerts.pushError('Error', resp); | ||||
| 				}) | ||||
| 			} | ||||
| 		}, | ||||
| 		created: function() { | ||||
|  | ||||
| 			this.id = usrData._id; | ||||
| 			this.email = usrData.email; | ||||
| 			this.name = usrData.name; | ||||
|  | ||||
| 			if(_.find(usrData.rights, { role: 'admin' })) { | ||||
| 				this.rights = _.reject(usrData.rights, ['role', 'admin']); | ||||
| 				this.roleoverride = 'admin'; | ||||
| 			} else { | ||||
| 				this.rights = usrData.rights; | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| 	//=include ../modals/admin-users-delete.js | ||||
|  | ||||
| } | ||||
| 	// =include ../modals/admin-users-delete.js | ||||
| } | ||||
|   | ||||
| @@ -1,14 +1,12 @@ | ||||
|  | ||||
| if($('#page-type-create').length) { | ||||
| if ($('#page-type-create').length) { | ||||
|   let pageEntryPath = $('#page-type-create').data('entrypath') | ||||
|  | ||||
| 	let pageEntryPath = $('#page-type-create').data('entrypath'); | ||||
| 	// -> Discard | ||||
|  | ||||
| 	//-> Discard | ||||
|   $('.btn-create-discard').on('click', (ev) => { | ||||
|     $('#modal-create-discard').toggleClass('is-active') | ||||
|   }) | ||||
|  | ||||
| 	$('.btn-create-discard').on('click', (ev) => { | ||||
| 		$('#modal-create-discard').toggleClass('is-active'); | ||||
| 	}); | ||||
|  | ||||
| 	//=include ../components/editor.js | ||||
|  | ||||
| } | ||||
| 	// =include ../components/editor.js | ||||
| } | ||||
|   | ||||
| @@ -1,14 +1,12 @@ | ||||
|  | ||||
| if($('#page-type-edit').length) { | ||||
| if ($('#page-type-edit').length) { | ||||
|   let pageEntryPath = $('#page-type-edit').data('entrypath') | ||||
|  | ||||
| 	let pageEntryPath = $('#page-type-edit').data('entrypath'); | ||||
| 	// -> Discard | ||||
|  | ||||
| 	//-> Discard | ||||
|   $('.btn-edit-discard').on('click', (ev) => { | ||||
|     $('#modal-edit-discard').toggleClass('is-active') | ||||
|   }) | ||||
|  | ||||
| 	$('.btn-edit-discard').on('click', (ev) => { | ||||
| 		$('#modal-edit-discard').toggleClass('is-active'); | ||||
| 	}); | ||||
|  | ||||
| 	//=include ../components/editor.js | ||||
|  | ||||
| } | ||||
| 	// =include ../components/editor.js | ||||
| } | ||||
|   | ||||
| @@ -1,18 +1,16 @@ | ||||
|  | ||||
| if($('#page-type-source').length) { | ||||
| if ($('#page-type-source').length) { | ||||
|   var scEditor = ace.edit('source-display') | ||||
|   scEditor.setTheme('ace/theme/tomorrow_night') | ||||
|   scEditor.getSession().setMode('ace/mode/markdown') | ||||
|   scEditor.setOption('fontSize', '14px') | ||||
|   scEditor.setOption('hScrollBarAlwaysVisible', false) | ||||
|   scEditor.setOption('wrap', true) | ||||
|   scEditor.setReadOnly(true) | ||||
|   scEditor.renderer.updateFull() | ||||
|  | ||||
| 	var scEditor = ace.edit("source-display"); | ||||
|   scEditor.setTheme("ace/theme/tomorrow_night"); | ||||
|   scEditor.getSession().setMode("ace/mode/markdown"); | ||||
|   scEditor.setOption('fontSize', '14px'); | ||||
|   scEditor.setOption('hScrollBarAlwaysVisible', false); | ||||
| 	scEditor.setOption('wrap', true); | ||||
|   scEditor.setReadOnly(true); | ||||
|   scEditor.renderer.updateFull(); | ||||
|   let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : '' | ||||
|  | ||||
|   let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : ''; | ||||
|  | ||||
|   //=include ../modals/create.js | ||||
| 	//=include ../modals/move.js | ||||
|  | ||||
| } | ||||
|   // =include ../modals/create.js | ||||
| 	// =include ../modals/move.js | ||||
| } | ||||
|   | ||||
| @@ -1,9 +1,7 @@ | ||||
|  | ||||
| if($('#page-type-view').length) { | ||||
| if ($('#page-type-view').length) { | ||||
|   let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '' | ||||
|  | ||||
| 	let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : ''; | ||||
|  | ||||
| 	//=include ../modals/create.js | ||||
| 	//=include ../modals/move.js | ||||
|  | ||||
| } | ||||
| 	// =include ../modals/create.js | ||||
| 	// =include ../modals/move.js | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user