File modules/cms/ui/themes/default/script/openrat/dialog.min.js

Last commit: Fri Feb 11 01:41:54 2022 +0100	dankert	Fix: Reading dirty marker.
1 import $ from "../jquery-global.min.js"; 2 import View from './view.min.js'; 3 import Notice from "./notice.min.js"; 4 import Workbench from "./workbench.min.js"; 5 import WorkbenchNavigator from "./navigator.min.js"; 6 export default class Dialog { 7 constructor() { 8 this.view; 9 this.element = $('.or-dialog-content .or-view'); 10 } 11 set isDirty( dirty ) { 12 if ( dirty ) 13 this.element.addClass('view--is-dirty'); 14 else 15 this.element.removeClass('view--is-dirty'); 16 } 17 get isDirty() { 18 return this.element.hasClass('view--is-dirty'); 19 } 20 start( name,action,method,id,params ) 21 { 22 if (!action) 23 action = Workbench.state.action; 24 if (!id) 25 id = Workbench.state.id; 26 let dialog = this; 27 let view = new View( action,method,id,params ); 28 Notice.removeAllNotices(); 29 $('.or-dialog-content .or-view').html(''); 30 $('.or-dialog-content .or-act-dialog-name').html( name ); 31 this.show(); 32 view.onCloseHandler.add( function() { 33 dialog.back(); 34 } ); 35 view.onChangeHandler.add( function() { 36 console.debug("Changes detected"); 37 dialog.isDirty = true; 38 }); 39 view.onSaveHandler.add( function() { 40 dialog.isDirty = false; 41 }); 42 this.view = view; 43 Workbench.getInstance().startSpinner(); 44 let viewPromise = this.view.start( this.element ); 45 viewPromise.then( 46 () => Workbench.getInstance().stopSpinner() 47 ); 48 return viewPromise; 49 } 50 show() { 51 WorkbenchNavigator.navigateToNew( Workbench.state ); 52 $('.or-dialog').removeClass('dialog--is-closed').addClass('dialog--is-open'); 53 if ( this.isDirty ) { 54 this.element.addClass('view--is-dirty'); 55 } 56 } 57 back() { 58 console.debug("Back from dialog"); 59 history.back(); 60 } 61 hide() { 62 $('.or-dialog').removeClass('dialog--is-open').addClass('dialog--is-closed'); 63 } 64 close() { 65 let dialog = this; 66 if ( this.isDirty ) { 67 // return; 68 let notice = new Notice(); 69 notice.msg = Workbench.language.REOPEN_CLOSED_DIALOG; 70 notice.setStatus( 'warning' ); 71 notice.timeout = 120; 72 notice.onClick.add( function() { 73 Workbench.dialog = dialog; 74 dialog.show(); 75 notice.close(); 76 }); 77 notice.show(); 78 } 79 $('.or-dialog-content .or-view.or-view--is-dirty').removeClass('view--is-dirty'); 80 this.hide(); 81 //$(document).unbind('keyup',this.escapeKeyClosingHandler); 82 } 83 }
Download modules/cms/ui/themes/default/script/openrat/dialog.min.js
History Fri, 11 Feb 2022 01:41:54 +0100 dankert Fix: Reading dirty marker. Fri, 11 Feb 2022 01:28:51 +0100 dankert Fixed some UI problems: The dialogs are now closed after submitting the data; Workbench is reloaded after login/logout. Sat, 18 Dec 2021 03:47:23 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments.