openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit aa116e74b6790b656b8db3ed4eff5f39ef21649a
parent 8c848680e4299ec6eeef4e188ba8b18529a79c44
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu, 18 Feb 2021 01:55:01 +0100

New: Action for displaying a navigation while no other action is selected.

Diffstat:
Mmodules/cms/Dispatcher.class.php | 2+-
Mmodules/cms/action/Method.class.php | 31++++++++++++++++++++++++++++++-
Mmodules/cms/ui/UI.class.php | 2+-
Amodules/cms/ui/action/UsergroupAction.class.php | 47+++++++++++++++++++++++++++++++++++++++++++++++
Amodules/cms/ui/action/index/IndexEditAction.class.php | 42++++++++++++++++++++++++++++++++++++++++++
Amodules/cms/ui/action/usergroup/UsergroupEditAction.class.php | 42++++++++++++++++++++++++++++++++++++++++++
Amodules/cms/ui/themes/default/html/views/index/edit.php | 23+++++++++++++++++++++++
Amodules/cms/ui/themes/default/html/views/index/edit.tpl.src.xml | 23+++++++++++++++++++++++
Amodules/cms/ui/themes/default/html/views/usergroup/edit.php | 32++++++++++++++++++++++++++++++++
Rmodules/cms/ui/themes/default/html/views/usergroup/show.tpl.src.xml -> modules/cms/ui/themes/default/html/views/usergroup/edit.tpl.src.xml | 0
Dmodules/cms/ui/themes/default/html/views/usergroup/show.php | 32--------------------------------
Mmodules/cms/ui/themes/default/script/openrat.js | 13+++++++++++--
Mmodules/cms/ui/themes/default/script/openrat.min.js | 4++--
Mmodules/cms/ui/themes/default/script/openrat/common.js | 7++++++-
Mmodules/cms/ui/themes/default/script/openrat/view.js | 6+++++-
15 files changed, 265 insertions(+), 41 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -328,7 +328,7 @@ class Dispatcher $action = strtolower( $baseActionClassName->dropNamespace()->dropSuffix('Action')->get() ); if ( ! $action ) { - throw new BadMethodCallException( 'Action not found' ); + throw new BadMethodCallException( TextMessage::create( 'No action found for action ${0} and method ${1}',[$this->request->action,$this->request->method] ) ); } } diff --git a/modules/cms/action/Method.class.php b/modules/cms/action/Method.class.php @@ -3,10 +3,39 @@ namespace cms\action; - +/** + * Method. + * + * A Method is divided into + * - a view and + * - a post action. + * + * Every Method must implement this interface. + * + * @package cms\action + */ interface Method { + /** + * View. + * + * View action for displaying data. + * Normally this is called after a HTTP GET. + * This method needs to be idempotent, this usually means that no data is written to the model. + * This method should be readonly, but may write data to the session. + * + * @return void + */ public function view(); + /** + * Post action. + * + * Post action for writing data to the model (and the database). + * + * Normally this is called after a HTTP POST. + * + * @return void + */ public function post(); } \ No newline at end of file diff --git a/modules/cms/ui/UI.class.php b/modules/cms/ui/UI.class.php @@ -55,7 +55,7 @@ class UI if ( $request->isAction ) throw new \RuntimeException('The UI does not accept POST requests'); - if ( in_array( $request->action,['index','tree','title']) ) + if ( in_array( $request->action,['index','tree','title','usergroup']) ) $request->isUIAction = true; UI::executeAction($request); diff --git a/modules/cms/ui/action/UsergroupAction.class.php b/modules/cms/ui/action/UsergroupAction.class.php @@ -0,0 +1,47 @@ +<?php + +namespace cms\ui\action; + +use cms\action\Action; +use cms\action\RequestParams; +use cms\auth\Auth; +use cms\auth\AuthRunner; +use cms\base\Configuration; +use cms\base\Configuration as C; +use cms\base\Startup; +use cms\model\BaseObject; +use cms\model\Project; +use cms\model\User; +use cms\model\Value; +use cms\ui\themes\Theme; +use Exception; +use language\Messages; +use util\Html; +use util\json\JSON; +use logger\Logger; +use util\Less; +use util\UIUtils; +use \util\exception\ObjectNotFoundException; +use util\Session; + + +/** + * Action-Klasse fuer die Anzeige der Hauptseite. + * + * @author Jan Dankert + * @package openrat.actions + */ +class UsergroupAction extends Action +{ + public $security = Action::SECURITY_ADMIN; + + + /** + * Konstruktor + */ + function __construct() + { + parent::__construct(); + } + +} diff --git a/modules/cms/ui/action/index/IndexEditAction.class.php b/modules/cms/ui/action/index/IndexEditAction.class.php @@ -0,0 +1,42 @@ +<?php +namespace cms\ui\action\index; +use cms\action\Method; +use cms\model\User; +use cms\ui\action\IndexAction; +use cms\ui\themes\ThemeStyle; +use language\Messages; +use util\Html; +use util\Session; +use util\UIUtils; +use cms\base\Configuration as C; +use cms\action\RequestParams; +use cms\auth\Auth; +use cms\auth\AuthRunner; +use cms\base\Configuration; +use cms\base\Startup; +use cms\model\BaseObject; +use cms\model\Project; +use cms\model\Value; +use cms\ui\themes\Theme; +use Exception; +use util\json\JSON; +use logger\Logger; +use util\Less; +use \util\exception\ObjectNotFoundException; + +/** + * Main action, displayed after starting the UI. + * + * @package cms\ui\action\index + */ +class IndexEditAction extends IndexAction implements Method { + + public function view() { + + $this->setTemplateVar('isAdmin',$this->userIsAdmin() ); + } + + + public function post() { + } +} diff --git a/modules/cms/ui/action/usergroup/UsergroupEditAction.class.php b/modules/cms/ui/action/usergroup/UsergroupEditAction.class.php @@ -0,0 +1,42 @@ +<?php +namespace cms\ui\action\usergroup; +use cms\action\Method; +use cms\model\User; +use cms\ui\action\IndexAction; +use cms\ui\themes\ThemeStyle; +use language\Messages; +use util\Html; +use util\Session; +use util\UIUtils; +use cms\base\Configuration as C; +use cms\action\RequestParams; +use cms\auth\Auth; +use cms\auth\AuthRunner; +use cms\base\Configuration; +use cms\base\Startup; +use cms\model\BaseObject; +use cms\model\Project; +use cms\model\Value; +use cms\ui\themes\Theme; +use Exception; +use util\json\JSON; +use logger\Logger; +use util\Less; +use \util\exception\ObjectNotFoundException; + +/** + * Simple action to display a navigation. + * + * @package cms\ui\action\index + */ +class UsergroupEditAction extends IndexAction implements Method { + + public function view() { + // no data is needed to display the template. + } + + + public function post() { + // no data is written. + } +} diff --git a/modules/cms/ui/themes/default/html/views/index/edit.php b/modules/cms/ui/themes/default/html/views/index/edit.php @@ -0,0 +1,22 @@ +<?php /* THIS FILE IS GENERATED from edit.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?> + <div class="<?php echo O::escapeHtml('or-linklist') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-act-clickable or-linklist-line or-round-corners or-hover-effect') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('projectlist') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/projectlist') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('projects').'') ?></span> + </a> + </div> + <?php $if3=($isAdmin); if($if3) { ?> + <div class="<?php echo O::escapeHtml('or-act-clickable or-linklist-line or-round-corners or-hover-effect') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('usergroup') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/usergroup') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('user_and_groups').'') ?></span> + </a> + </div> + <?php } ?> + <?php $if3=($isAdmin); if($if3) { ?> + <div class="<?php echo O::escapeHtml('or-act-clickable or-linklist-line or-round-corners or-hover-effect') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('configuration') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/configuration') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('prefs').'') ?></span> + </a> + </div> + <?php } ?> + </div>+ \ No newline at end of file diff --git a/modules/cms/ui/themes/default/html/views/index/edit.tpl.src.xml b/modules/cms/ui/themes/default/html/views/index/edit.tpl.src.xml @@ -0,0 +1,23 @@ +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> + <part class="linklist"> + <part class="act-clickable,linklist-line,round-corners,hover-effect"> + <link type="open" action="projectlist"> + <text value="${message:projects}"/> + </link> + </part> + <if true="${isAdmin}"> + <part class="act-clickable,linklist-line,round-corners,hover-effect"> + <link type="open" action="usergroup"> + <text value="${message:user_and_groups}"/> + </link> + </part> + </if> + <if true="${isAdmin}"> + <part class="act-clickable,linklist-line,round-corners,hover-effect"> + <link type="open" action="configuration"> + <text value="${message:prefs}"/> + </link> + </part> + </if> + </part> +</output> diff --git a/modules/cms/ui/themes/default/html/views/usergroup/edit.php b/modules/cms/ui/themes/default/html/views/usergroup/edit.php @@ -0,0 +1,31 @@ +<?php /* THIS FILE IS GENERATED from edit.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?> + <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> + <div class="<?php echo O::escapeHtml('or-table-filter') ?>"><?php echo O::escapeHtml('') ?> + <input type="<?php echo O::escapeHtml('search') ?>" name="<?php echo O::escapeHtml('filter') ?>" placeholder="<?php echo O::escapeHtml(''.@O::lang('SEARCH_FILTER').'') ?>" class="<?php echo O::escapeHtml('or-input or-table-filter-input') ?>" /><?php echo O::escapeHtml('') ?> + </div> + <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> + <table width="<?php echo O::escapeHtml('100%') ?>" class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> + <tr class="<?php echo O::escapeHtml('or-headline') ?>"><?php echo O::escapeHtml('') ?> + <td><?php echo O::escapeHtml('') ?> + <span><?php echo O::escapeHtml(''.@O::lang('name').'') ?></span> + </td> + </tr> + <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> + <td data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-action="<?php echo O::escapeHtml('userlist') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('userlist') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/userlist') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-user') ?>"><?php echo O::escapeHtml('') ?></i> + <span><?php echo O::escapeHtml(''.@O::lang('users').'') ?></span> + </a> + </td> + </tr> + <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> + <td data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-action="<?php echo O::escapeHtml('grouplist') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> + <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('grouplist') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/grouplist') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> + <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-group') ?>"><?php echo O::escapeHtml('') ?></i> + <span><?php echo O::escapeHtml(''.@O::lang('groups').'') ?></span> + </a> + </td> + </tr> + </table> + </div> + </div>+ \ No newline at end of file diff --git a/modules/cms/ui/themes/default/html/views/usergroup/show.tpl.src.xml b/modules/cms/ui/themes/default/html/views/usergroup/edit.tpl.src.xml diff --git a/modules/cms/ui/themes/default/html/views/usergroup/show.php b/modules/cms/ui/themes/default/html/views/usergroup/show.php @@ -1,31 +0,0 @@ -<?php /* THIS FILE IS GENERATED from show.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?> - <div class="<?php echo O::escapeHtml('or-table-wrapper') ?>"><?php echo O::escapeHtml('') ?> - <div class="<?php echo O::escapeHtml('or-table-filter') ?>"><?php echo O::escapeHtml('') ?> - <input type="<?php echo O::escapeHtml('search') ?>" name="<?php echo O::escapeHtml('filter') ?>" placeholder="<?php echo O::escapeHtml(''.@O::lang('SEARCH_FILTER').'') ?>" class="<?php echo O::escapeHtml('or-input or-table-filter-input') ?>" /><?php echo O::escapeHtml('') ?> - </div> - <div class="<?php echo O::escapeHtml('or-table-area') ?>"><?php echo O::escapeHtml('') ?> - <table width="<?php echo O::escapeHtml('100%') ?>" class="<?php echo O::escapeHtml('or-table') ?>"><?php echo O::escapeHtml('') ?> - <tr class="<?php echo O::escapeHtml('or-headline') ?>"><?php echo O::escapeHtml('') ?> - <td><?php echo O::escapeHtml('') ?> - <span><?php echo O::escapeHtml(''.@O::lang('name').'') ?></span> - </td> - </tr> - <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> - <td data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-action="<?php echo O::escapeHtml('userlist') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> - <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('userlist') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/userlist') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> - <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-user') ?>"><?php echo O::escapeHtml('') ?></i> - <span><?php echo O::escapeHtml(''.@O::lang('users').'') ?></span> - </a> - </td> - </tr> - <tr class="<?php echo O::escapeHtml('or-data') ?>"><?php echo O::escapeHtml('') ?> - <td data-name="<?php echo O::escapeHtml(''.@$name.'') ?>" data-action="<?php echo O::escapeHtml('grouplist') ?>" data-id="<?php echo O::escapeHtml(''.@$id.'') ?>" class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> - <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('open') ?>" data-action="<?php echo O::escapeHtml('grouplist') ?>" data-method="<?php echo O::escapeHtml('') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra="<?php echo O::escapeHtml('[]') ?>" href="<?php echo O::escapeHtml('#/grouplist') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> - <i class="<?php echo O::escapeHtml('or-image-icon or-image-icon--action-group') ?>"><?php echo O::escapeHtml('') ?></i> - <span><?php echo O::escapeHtml(''.@O::lang('groups').'') ?></span> - </a> - </td> - </tr> - </table> - </div> - </div>- \ No newline at end of file diff --git a/modules/cms/ui/themes/default/script/openrat.js b/modules/cms/ui/themes/default/script/openrat.js @@ -2037,7 +2037,7 @@ Openrat.View = function( action,method,id,params ) { if ( ! data ) data = ''; - $(element).html(data).removeClass("loader"); + $(element).html(data); $(element).find('form').each( function() { @@ -2080,6 +2080,10 @@ Openrat.View = function( action,method,id,params ) { notice.show(); }); + loadViewHtmlPromise.always( function() { + $(element).removeClass("loader"); + }); + // Load the data for this view. let apiUrl = Openrat.View.createUrl( this.action,this.method,this.id,this.params,true); @@ -3068,7 +3072,12 @@ $( function() { }).fail(function ( jqXHR, textStatus, errorThrown ) { // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen. - console.warn( {message:'Failed to load path',url:url,error:e,status:textStatus,errorThrown } ); + console.warn( { + message:'Failed to load path', + url :url, + jqXHR :jqXHR, + status :textStatus, + error :errorThrown } ); }).always(function () { }); diff --git a/modules/cms/ui/themes/default/script/openrat.min.js b/modules/cms/ui/themes/default/script/openrat.min.js @@ -1175,7 +1175,7 @@ jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",undo:"Undo",redo:"Redo",format else if(Notification.permission==='granted'){let notification=new Notification(t)} else if(Notification.permission!=='denied'){Notification.requestPermission(function(e){if(e==='granted'){let notification=new Notification(t)}})}};let htmlEntities=function(t){return String(t).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;')}};Openrat.Notice.removeNoticesWithStatus=function(t){$('.or-notices').find('.or-notice--'+t).remove()};Openrat.Notice.removeAllNotices=function(t){$('.or-notices').find('.or-notice').remove()}; ;Openrat.Dialog=function(){this.view;this.isDirty=!1;this.element=$('.or-dialog-content .or-view');this.start=function(e,i,t,o,n){if(!i)i=Openrat.Workbench.state.action;if(!o)o=Openrat.Workbench.state.id;let dialog=this;let view=new Openrat.View(i,t,o,n);Openrat.Notice.removeAllNotices();$('.or-dialog').removeClass('dialog--is-closed').addClass('dialog--is-open');$('.or-dialog-content .or-act-dialog-name').html(e);this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){dialog.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('.or-dialog-filler,.or-act-dialog-close').off('click').click(function(e){e.preventDefault();dialog.close()});view.onCloseHandler.add(function(){dialog.close()});view.onChangeHandler.add(function(){console.debug('Changes detected');dialog.isDirty=!0;dialog.element.addClass('view--is-dirty')});view.onSaveHandler.add(function(){dialog.isDirty=!1;dialog.element.removeClass('view--is-dirty')});this.view=view;return this.view.start(this.element)};this.close=function(){if(this.isDirty){let exit=window.confirm(Openrat.Workbench.language.UNSAVED_CHANGES_CONFIRM);if(!exit)return};$('.or-dialog-content .or-view.or-view--is-dirty').removeClass('view--is-dirty');$('.or-dialog-content .or-view').html('');$('.or-dialog').removeClass('dialog--is-open').addClass('dialog--is-closed');$(document).unbind('keyup',this.escapeKeyClosingHandler)}}; -;Openrat.View=function(e,t,i,n){this.action=e;this.method=t;this.id=i;this.params=n;this.onCloseHandler=$.Callbacks();this.onChangeHandler=$.Callbacks();this.onSaveHandler=$.Callbacks();this.before=function(){};this.start=function(e){this.before();this.element=e;return this.loadView()};this.afterLoad=function(){};this.close=function(){this.onCloseHandler.fire()};function r(e){Openrat.Workbench.afterViewLoadedHandler.fire(e)};this.loadView=function(){let url=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=$.ajax(url);$(this.element).addClass('loader');console.debug(view);loadViewHtmlPromise.done(function(e,t){if(!e)e='';$(element).html(e).removeClass('loader');$(element).find('form').each(function(){let form=new Openrat.Form();form.onChangeHandler.add(function(){view.onChangeHandler.fire()});form.onSaveHandler.add(function(){view.onSaveHandler.fire()});form.onCloseHandler.add(function(){view.close()});form.forwardTo=function(e,t,i,n){view.action=e;view.method=t;view.id=i;view.params=n;view.loadView()};form.initOnElement(this)});r(element)});loadViewHtmlPromise.fail(function(e,t,i){$(element).html('');console.error({view:view,url:url,status:t,cause:i});let notice=new Openrat.Notice();notice.setStatus('error');notice.msg=Openrat.Workbench.language.ERROR;notice.show()});let apiUrl=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!0);return loadViewHtmlPromise};Openrat.View.createUrl=function(e,subaction,i,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(e)url+='&action='+e;if(subaction)url+='&subaction='+subaction;if(i)url+='&id='+i;if(typeof extraid==='string'){extraid=extraid.replace(/'/g,'"');let extraObject=jQuery.parseJSON(extraid);jQuery.each(extraObject,function(e,t){url=url+'&'+e+'='+t})} +;Openrat.View=function(e,t,i,n){this.action=e;this.method=t;this.id=i;this.params=n;this.onCloseHandler=$.Callbacks();this.onChangeHandler=$.Callbacks();this.onSaveHandler=$.Callbacks();this.before=function(){};this.start=function(e){this.before();this.element=e;return this.loadView()};this.afterLoad=function(){};this.close=function(){this.onCloseHandler.fire()};function a(e){Openrat.Workbench.afterViewLoadedHandler.fire(e)};this.loadView=function(){let url=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=$.ajax(url);$(this.element).addClass('loader');console.debug(view);loadViewHtmlPromise.done(function(e,t){if(!e)e='';$(element).html(e);$(element).find('form').each(function(){let form=new Openrat.Form();form.onChangeHandler.add(function(){view.onChangeHandler.fire()});form.onSaveHandler.add(function(){view.onSaveHandler.fire()});form.onCloseHandler.add(function(){view.close()});form.forwardTo=function(e,t,i,n){view.action=e;view.method=t;view.id=i;view.params=n;view.loadView()};form.initOnElement(this)});a(element)});loadViewHtmlPromise.fail(function(e,t,i){$(element).html('');console.error({view:view,url:url,status:t,cause:i});let notice=new Openrat.Notice();notice.setStatus('error');notice.msg=Openrat.Workbench.language.ERROR;notice.show()});loadViewHtmlPromise.always(function(){$(element).removeClass('loader')});let apiUrl=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!0);return loadViewHtmlPromise};Openrat.View.createUrl=function(e,subaction,i,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(e)url+='&action='+e;if(subaction)url+='&subaction='+subaction;if(i)url+='&id='+i;if(typeof extraid==='string'){extraid=extraid.replace(/'/g,'"');let extraObject=jQuery.parseJSON(extraid);jQuery.each(extraObject,function(e,t){url=url+'&'+e+'='+t})} else if(typeof extraid==='object'){jQuery.each(extraid,function(e,t){url=url+'&'+e+'='+t})} else{};return url}}; ;Openrat.Form=function(){const modes={showBrowserNotice:1,keepOpen:2,closeAfterSubmit:4,closeAfterSuccess:8,};this.onChangeHandler=$.Callbacks();this.onSaveHandler=$.Callbacks();this.setLoadStatus=function(e){$(this.element).closest('div.content').toggleClass('loader',e)};this.initOnElement=function(e){this.element=e;let form=this;if($(this.element).data('autosave')){$(this.element).find('input[type="checkbox"]').click(function(){form.submit(modes.keepOpen)});$(this.element).find('select').change(function(){form.submit(modes.keepOpen)})};$(e).find('.or-act-form-cancel').click(function(){form.cancel()});$(e).find('.or-act-form-reset').click(function(){form.rollback()});$(e).find('.or-act-form-apply').click(function(){form.submit(modes.keepOpen)});$(e).find('.or-act-form-save').click(function(){form.submit()});$(e).find('.or-input').change(function(){form.onChangeHandler.fire()});$(e).submit(function(e){if($(this).data('target')=='view'){form.submit();e.preventDefault()}})};this.cancel=function(){Openrat.Notice.removeAllNotices();this.onCloseHandler.fire()};this.rollback=function(){this.element.trigger('reset')};this.onCloseHandler=$.Callbacks();this.forwardTo=function(e,t,o,s){};this.submit=function(e){if(e===undefined)if($(this.element).data('async'))e=modes.closeAfterSubmit;else e=modes.closeAfterSuccess;Openrat.Notice.removeAllNotices();let status=new Openrat.Notice();status.setStatus('info');status.inProgress();status.msg=Openrat.Workbench.language.PROGRESS;status.show();$(this.element).find('.or-input--error').removeClass('input--error');let params=$(this.element).serializeArray();let data={};$(params).each(function(e,t){data[t.name]=t.value});if(!data.id)data.id=Openrat.Workbench.state.id;if(!data.action)data.action=Openrat.Workbench.state.action;let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(data.action,data.subaction,data.id,data);$(status).remove()} @@ -1187,7 +1187,7 @@ else{}});$.each(e['errors'],function(e,t){$('.or-input[name='+t+']').addClass('i else{return undefined}})};this.openModalDialog=function(){if($('#dialog').data('action')){let dialog=new Openrat.Dialog();dialog.start('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.getJSON(Openrat.View.createUrl('profile','ping',0,{},!0));console.debug('ping');pingPromise.fail(function(e,t,i){console.warn({message:'The server ping has failed.',jqXHR:e,status:t,error:i});if($('.view.dirty').length>0){window.alert('The server session is lost, please save your data.')} else{}})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};this.loadNewActionState=function(e){Openrat.Workbench.state=e;Openrat.Workbench.loadNewAction(e.action,e.id,e.data);this.afterNewActionHandler.fire()};this.afterNewActionHandler=$.Callbacks();this.afterAllViewsLoaded=$.Callbacks();this.loadNewAction=function(e,t,i){this.reloadViews()};this.reloadViews=function(){$('.or-workbench-section--is-closed .or-act-view-loader').empty();let promise=Openrat.Workbench.loadViews($('.or-workbench .or-act-view-loader'));promise.done(function(){Openrat.Workbench.afterAllViewsLoaded.fire()});return promise};this.reloadAll=function(){let promise=Openrat.Workbench.loadViews($('.or-act-view-loader,.or-act-view-static').empty());console.debug('reloading all views');promise.done(function(){Openrat.Workbench.afterAllViewsLoaded.fire()});this.loadUserStyle();this.loadLanguage();this.loadUISettings();return promise};this.loadUserStyle=function(){let url=Openrat.View.createUrl('profile','userinfo',0,{},!0);$.getJSON(url,function(e){let style=e.output['style'];Openrat.Workbench.setUserStyle(style);let color=e.output['theme-color'];Openrat.Workbench.setThemeColor(color)})};this.settings={};this.language={};this.loadLanguage=function(){let url=Openrat.View.createUrl('profile','language',0,{},!0);$.getJSON(url,function(e){Openrat.Workbench.language=e.output.language})};this.loadUISettings=function(){let url=Openrat.View.createUrl('profile','uisettings',0,{},!0);$.getJSON(url,function(e){Openrat.Workbench.settings=e.output.settings.settings})};this.loadViews=function(e){let promises=[];e.each(function(e){let $targetDOMElement=$(this);promises.push(Openrat.Workbench.loadNewActionIntoElement($targetDOMElement))});return $.when.apply($,promises)};this.loadNewActionIntoElement=function(e){let action;if(e.is('.or-act-view-static'))action=e.attr('data-action');else action=Openrat.Workbench.state.action;let id=Openrat.Workbench.state.id;let params=Openrat.Workbench.state.extra;let method=e.data('method');let view=new Openrat.View(action,method,id,params);return view.start(e)};this.setUserStyle=function(e){var t=$('html'),i=t.attr('class').split(/\s+/);$.each(i,function(e,i){if(i.startsWith('or-theme-')){t.removeClass(i.substring(3))}});t.addClass('theme-'+e.toLowerCase())};this.setThemeColor=function(e){$('#theme-color').attr('content',e)};this.dataChangedHandler=$.Callbacks();this.dataChangedHandler.add(function(){if(Openrat.Workbench.popupWindow)Openrat.Workbench.popupWindow.location.reload()});this.afterViewLoadedHandler=$.Callbacks();this.setApplicationTitle=function(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};this.registerOpenClose=function(e){$(e).children('.or-collapsible-act-switch').click(function(){$(this).closest('.or-collapsible').toggleClass('collapsible--is-open').toggleClass('collapsible--is-closed')})};this.openNewAction=function(e,t,i){$('.or-workbench-navigation').removeClass('workbench-navigation--is-open');Openrat.Workbench.setApplicationTitle(e);Openrat.Navigator.navigateToNew({'action':t,'id':i})};this.registerDraggable=function(e){$(e).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:3,distance:10,cursor:'move',revert:'false'})};this.registerDroppable=function(e){$(e).find('.or-droppable-selector').droppable({accept:'.or-draggable',hoverClass:'droppable--hover',activeClass:'droppable--active',drop:function(e,t){let dropped=t.draggable;console.info('dropped:');console.info(dropped);let id=$(dropped).find('.or-link').data('id');let name=$(dropped).find('.or-navtree-text').text();if(!name)name=id;$(this).find('.or-selector-link-value').val(id);$(this).find('.or-selector-link-name').val(name).attr('placeholder',name)}})}}; ;Openrat.Navigator=new function(){'use strict';this.navigateTo=function(t){Openrat.Workbench.loadNewActionState(t)};this.navigateToNew=function(t){this.navigateTo(t);window.history.pushState(t,t.name,this.createShortUrl(t.action,t.id))};this.toActualHistory=function(t){window.history.replaceState(t,t.name,this.createShortUrl(t.action,t.id))};this.createShortUrl=function(t,i){return'./#/'+t+(i?'/'+i:'')}}; -;$(function(){$('html').removeClass('nojs');$('.or--initial-hidden').removeClass('-initial-hidden');function t(){};t();window.onpopstate=function(e){Openrat.Navigator.navigateTo(e.state)};Openrat.Workbench.initialize();Openrat.Workbench.reloadAll();let registerWorkbenchGlobalEvents=function(){$('.keystroke').each(function(){let keystrokeElement=$(this);let keystroke=keystrokeElement.text();if(keystroke.length==0)return;let keyaction=function(){keystrokeElement.click()};$(document).bind('keydown',keystroke,keyaction)})};$('.or-act-initial-notice').each(function(){let notice=new Openrat.Notice();notice.setStatus('info');notice.msg=$(this).text();notice.show();$(this).remove()});registerWorkbenchGlobalEvents();let closeMenu=function(){$('body').click(function(){$('.or-menu').removeClass('menu--is-open')})};closeMenu();let closeMobileNavigation=function(){$('.or-act-navigation-close').click(function(){$('.or-workbench-navigation').removeClass('workbench-navigation--is-open');$('.or-workbench').removeClass('workbench--navigation-is-open')})};closeMobileNavigation();let closeDesktopNavigation=function(){$('.or-workbench-title .or-act-nav-small').click(function(){$('.or-workbench').addClass('workbench--navigation-is-small');$('.or-workbench-navigation').addClass('workbench-navigation--is-small')})};closeDesktopNavigation();let registerGlobalSearch=function(){$('.or-search-input .or-input').orSearch({onSearchActive:function(){$('.or-search').addClass('search--is-active')},onSearchInactive:function(){$('.or-search').removeClass('search--is-active')},dropdown:'.or-act-search-result',resultEntryClass:'or-search-result-entry',select:function(e){Openrat.Workbench.openNewAction(e.name,e.action,e.id)},afterSelect:function(){}});$('.or-search .or-act-search-delete').click(function(){$('.or-search .or-title-input').val('').change()})};registerGlobalSearch();Openrat.Workbench.afterNewActionHandler.add(function(){$('.or-sidebar').find('.or-sidebar-button').orLinkify()});Openrat.Workbench.afterNewActionHandler.add(function(){let url=Openrat.View.createUrl('tree','path',Openrat.Workbench.state.id,{'type':Openrat.Workbench.state.action});let loadPromise=$.get(url);loadPromise.done(function(e){$('.or-breadcrumb').empty().append(e).find('.or-act-clickable').orLinkify();$('nav .or-navtree-node').removeClass('or-navtree-node--selected');$('.or-breadcrumb a').each(function(){let action=$(this).data('action');let id=$(this).data('id');let $navControl=$('nav .or-navtree-node[data-type='+action+'][data-id='+id+'].or-navtree-node--is-closed .or-navtree-node-control');$navControl.click()})}).fail(function(t,n,o){console.warn({message:'Failed to load path',url:url,error:e,status:n,o})}).always(function(){})});Openrat.Workbench.afterNewActionHandler.fire()});let filterMenus=function(){let action=Openrat.Workbench.state.action;let id=Openrat.Workbench.state.id;$('.or-workbench-title .or-dropdown-entry.or-act-clickable').addClass('dropdown-entry--active');$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered').removeClass('dropdown-entry--active').addClass('dropdown-entry--inactive');$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered .or-link').attr('data-id',id);let url=Openrat.View.createUrl('profile','available',id,{'queryaction':action},!0);let promise=$.getJSON(url);promise.done(function(e){jQuery.each(e.output.views,function(e,t){$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered > .or-link[data-method=\''+t+'\']').parent().addClass('dropdown-entry--active').removeClass('dropdown-entry--inactive')})})};Openrat.Workbench.afterAllViewsLoaded.add(function(){filterMenus()});Openrat.Workbench.afterViewLoadedHandler.add(function(e){if(Openrat.Workbench.popupWindow)$(e).find('a[data-type=\'popup\']').each(function(){Openrat.Workbench.popupWindow.location.href=$(this).attr('data-url')})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){$(e).find('.or-input--password').dblclick(function(){$(this).toggleAttr('type','text','password')});$(e).find('.or-act-make-visible').click(function(){$(this).toggleClass('btn--is-active');$(this).parent().children('input').toggleAttr('type','text','password')})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){e.find('.or-act-load-nav-tree').each(function(){let type=$(this).data('type')||'root';let loadBranchUrl='./?action=tree&subaction=branch&id=0&type='+type;let $targetElement=$(this);$.get(loadBranchUrl).done(function(e){let $ul=$('<ul class="or-navtree-list" />');$ul.appendTo($targetElement.empty()).append(e);$ul.find('li').orTree({'openAction':function(e,t,n){Openrat.Workbench.openNewAction(e,t,n)}});$ul.find('.or-act-clickable').orLinkify();$ul.find('.or-navtree-node-control').first().click()})})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){var t=$(e).closest('section');t.toggleClass('is-empty',$(e).is(':empty'));if(!$(e).is(':empty'))t.slideDown('fast');else t.slideUp('fast');$(e).find('.or-act-nav-open-close').click(function(){$('.or-workbench').toggleClass('workbench--navigation-is-open');$('.or-workbench-navigation').toggleClass('workbench-navigation--is-open')});$(e).find('.or-act-nav-small').click(function(){$('.or-workbench').addClass('workbench--navigation-is-small');$('.or-workbench-navigation').addClass('workbench-navigation--is-small')});$(e).find('.or-act-nav-wide').click(function(){$('.or-workbench').removeClass('workbench--navigation-is-small');$('.or-workbench-navigation').removeClass('workbench-navigation--is-small')});$(e).find('.or-act-selector-tree-button').click(function(){let $selector=$(this).parent('.or-selector');let $targetElement=$selector.find('.or-act-load-selector-tree');if($selector.hasClass('selector--is-tree-active')){$selector.removeClass('selector--is-tree-active');$targetElement.empty()} +;$(function(){$('html').removeClass('nojs');$('.or--initial-hidden').removeClass('-initial-hidden');function e(){};e();window.onpopstate=function(e){Openrat.Navigator.navigateTo(e.state)};Openrat.Workbench.initialize();Openrat.Workbench.reloadAll();let registerWorkbenchGlobalEvents=function(){$('.keystroke').each(function(){let keystrokeElement=$(this);let keystroke=keystrokeElement.text();if(keystroke.length==0)return;let keyaction=function(){keystrokeElement.click()};$(document).bind('keydown',keystroke,keyaction)})};$('.or-act-initial-notice').each(function(){let notice=new Openrat.Notice();notice.setStatus('info');notice.msg=$(this).text();notice.show();$(this).remove()});registerWorkbenchGlobalEvents();let closeMenu=function(){$('body').click(function(){$('.or-menu').removeClass('menu--is-open')})};closeMenu();let closeMobileNavigation=function(){$('.or-act-navigation-close').click(function(){$('.or-workbench-navigation').removeClass('workbench-navigation--is-open');$('.or-workbench').removeClass('workbench--navigation-is-open')})};closeMobileNavigation();let closeDesktopNavigation=function(){$('.or-workbench-title .or-act-nav-small').click(function(){$('.or-workbench').addClass('workbench--navigation-is-small');$('.or-workbench-navigation').addClass('workbench-navigation--is-small')})};closeDesktopNavigation();let registerGlobalSearch=function(){$('.or-search-input .or-input').orSearch({onSearchActive:function(){$('.or-search').addClass('search--is-active')},onSearchInactive:function(){$('.or-search').removeClass('search--is-active')},dropdown:'.or-act-search-result',resultEntryClass:'or-search-result-entry',select:function(e){Openrat.Workbench.openNewAction(e.name,e.action,e.id)},afterSelect:function(){}});$('.or-search .or-act-search-delete').click(function(){$('.or-search .or-title-input').val('').change()})};registerGlobalSearch();Openrat.Workbench.afterNewActionHandler.add(function(){$('.or-sidebar').find('.or-sidebar-button').orLinkify()});Openrat.Workbench.afterNewActionHandler.add(function(){let url=Openrat.View.createUrl('tree','path',Openrat.Workbench.state.id,{'type':Openrat.Workbench.state.action});let loadPromise=$.get(url);loadPromise.done(function(e){$('.or-breadcrumb').empty().append(e).find('.or-act-clickable').orLinkify();$('nav .or-navtree-node').removeClass('or-navtree-node--selected');$('.or-breadcrumb a').each(function(){let action=$(this).data('action');let id=$(this).data('id');let $navControl=$('nav .or-navtree-node[data-type='+action+'][data-id='+id+'].or-navtree-node--is-closed .or-navtree-node-control');$navControl.click()})}).fail(function(e,t,n){console.warn({message:'Failed to load path',url:url,jqXHR:e,status:t,error:n})}).always(function(){})});Openrat.Workbench.afterNewActionHandler.fire()});let filterMenus=function(){let action=Openrat.Workbench.state.action;let id=Openrat.Workbench.state.id;$('.or-workbench-title .or-dropdown-entry.or-act-clickable').addClass('dropdown-entry--active');$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered').removeClass('dropdown-entry--active').addClass('dropdown-entry--inactive');$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered .or-link').attr('data-id',id);let url=Openrat.View.createUrl('profile','available',id,{'queryaction':action},!0);let promise=$.getJSON(url);promise.done(function(e){jQuery.each(e.output.views,function(e,t){$('.or-workbench-title .or-dropdown-entry.or-act-clickable.or-filtered > .or-link[data-method=\''+t+'\']').parent().addClass('dropdown-entry--active').removeClass('dropdown-entry--inactive')})})};Openrat.Workbench.afterAllViewsLoaded.add(function(){filterMenus()});Openrat.Workbench.afterViewLoadedHandler.add(function(e){if(Openrat.Workbench.popupWindow)$(e).find('a[data-type=\'popup\']').each(function(){Openrat.Workbench.popupWindow.location.href=$(this).attr('data-url')})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){$(e).find('.or-input--password').dblclick(function(){$(this).toggleAttr('type','text','password')});$(e).find('.or-act-make-visible').click(function(){$(this).toggleClass('btn--is-active');$(this).parent().children('input').toggleAttr('type','text','password')})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){e.find('.or-act-load-nav-tree').each(function(){let type=$(this).data('type')||'root';let loadBranchUrl='./?action=tree&subaction=branch&id=0&type='+type;let $targetElement=$(this);$.get(loadBranchUrl).done(function(e){let $ul=$('<ul class="or-navtree-list" />');$ul.appendTo($targetElement.empty()).append(e);$ul.find('li').orTree({'openAction':function(e,t,n){Openrat.Workbench.openNewAction(e,t,n)}});$ul.find('.or-act-clickable').orLinkify();$ul.find('.or-navtree-node-control').first().click()})})});Openrat.Workbench.afterViewLoadedHandler.add(function(e){var t=$(e).closest('section');t.toggleClass('is-empty',$(e).is(':empty'));if(!$(e).is(':empty'))t.slideDown('fast');else t.slideUp('fast');$(e).find('.or-act-nav-open-close').click(function(){$('.or-workbench').toggleClass('workbench--navigation-is-open');$('.or-workbench-navigation').toggleClass('workbench-navigation--is-open')});$(e).find('.or-act-nav-small').click(function(){$('.or-workbench').addClass('workbench--navigation-is-small');$('.or-workbench-navigation').addClass('workbench-navigation--is-small')});$(e).find('.or-act-nav-wide').click(function(){$('.or-workbench').removeClass('workbench--navigation-is-small');$('.or-workbench-navigation').removeClass('workbench-navigation--is-small')});$(e).find('.or-act-selector-tree-button').click(function(){let $selector=$(this).parent('.or-selector');let $targetElement=$selector.find('.or-act-load-selector-tree');if($selector.hasClass('selector--is-tree-active')){$selector.removeClass('selector--is-tree-active');$targetElement.empty()} else{$selector.addClass('selector--is-tree-active');var e=this;let id=$(this).data('init-folder-id');let type=id?'folder':'projects';let loadBranchUrl='./?action=tree&subaction=branch&id='+id+'&type='+type;$.get(loadBranchUrl).done(function(e){let $ul=$('<ul class="or-navtree-list" />');$ul.appendTo($targetElement).append(e);$ul.find('li').orTree({'openAction':function(e,t,n){$selector.find('.or-selector-link-value').val(n);$selector.find('.or-selector-link-name').val('').attr('placeholder',e);$selector.removeClass('selector--is-tree-active');$targetElement.empty()}});$ul.find('.or-act-clickable').orLinkify();$ul.find('.or-navtree-node-control').first().click()})}});n(e);$(e).find('.or-theme-chooser').change(function(){Openrat.Workbench.setUserStyle(this.value)});function o(e){$(e).find('.or-menu-category').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('menu--is-open')});$(e).find('.or-menu-category').mouseover(function(){$(this).parents('.or-menu').find('.or-menu-category').removeClass('menu-category--is-open');$(this).addClass('menu-category--is-open')})};function r(e){$(e).find('.or-act-selector-search').orSearch({onSearchActive:function(){$(this).parent('or-selector').addClass('selector-search--is-active')},onSearchInactive:function(){$(this).parent('or-selector').removeClass('selector-search--is-active')},dropdown:'.or-act-selector-search-results',resultEntryClass:'or-search-result-entry',select:function(t){$(e).find('.or-selector-link-value').val(t.id);$(e).find('.or-selector-link-name').val(t.name).attr('placeholder',t.name)},afterSelect:function(){$('.or-dropdown.or-act-selector-search-results').empty()}})};function a(e){};o(e);r(e);a(e);function n(e){Openrat.Workbench.registerDraggable(e);Openrat.Workbench.registerDroppable(e)};n(e)}); ;Openrat.Workbench.afterViewLoadedHandler.add(function(e){}); ;Openrat.Workbench.afterViewLoadedHandler.add(function(e){$(e).find('textarea').orAutoheight();$(e).find('textarea.or-editor.or-code-editor').each(function(){let mode=$(this).data('mode');let mimetype=$(this).data('mimetype');if(mimetype.length>0)mode=mimetype;let textareaEl=this;let editor=CodeMirror.fromTextArea(textareaEl,{lineNumbers:!0,viewportMargin:Infinity,mode:mode});editor.on('change',function(){let newValue=editor.getValue();$(textareaEl).val(newValue)});$(editor.getWrapperElement()).droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let pos=editor.getCursor();editor.setSelection(pos,pos);let insertText=dropped.data('id');let toInsert=''+insertText;editor.replaceSelection(toInsert)}})});$(e).find('textarea.or-editor.or-markdown-editor').each(function(){let textarea=this;let toolbar=[{name:'bold',action:SimpleMDE.toggleBold,className:'image-icon image-icon--editor-bold',title:'Bold',},{name:'italic',action:SimpleMDE.toggleItalic,className:'image-icon image-icon--editor-italic',title:'Italic',},{name:'heading',action:SimpleMDE.toggleHeadingBigger,className:'image-icon image-icon--editor-headline',title:'Headline',},'|',{name:'quote',action:SimpleMDE.toggleBlockquote,className:'image-icon image-icon--editor-quote',title:'Quote',},{name:'code',action:SimpleMDE.toggleCodeBlock,className:'image-icon image-icon--editor-code',title:'Code',},'|',{name:'generic list',action:SimpleMDE.toggleUnorderedList,className:'image-icon image-icon--editor-unnumberedlist',title:'Unnumbered list',},{name:'numbered list',action:SimpleMDE.toggleOrderedList,className:'image-icon image-icon--editor-numberedlist',title:'Numbered list',},'|',{name:'table',action:SimpleMDE.drawTable,className:'image-icon image-icon--editor-table',title:'Table',},{name:'horizontalrule',action:SimpleMDE.drawHorizontalRule,className:'image-icon image-icon--editor-horizontalrule',title:'Horizontal rule',},'|',{name:'undo',action:SimpleMDE.undo,className:'image-icon image-icon--editor-undo',title:'Undo',},{name:'redo',action:SimpleMDE.redo,className:'image-icon image-icon--editor-redo',title:'Redo',},'|',{name:'link',action:SimpleMDE.drawLink,className:'image-icon image-icon--editor-link',title:'Link',},{name:'image',action:SimpleMDE.drawImage,className:'image-icon image-icon--editor-image',title:'Image',},'|',{name:'guide',action:'https://simplemde.com/markdown-guide',className:'image-icon image-icon--editor-help',title:'Howto markdown',},];let mde=new SimpleMDE({element:$(this)[0],toolbar:toolbar,autoDownloadFontAwesome:!1});let codemirror=mde.codemirror;$(codemirror.getWrapperElement()).droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let insertText='';let id=dropped.data('id');let url='__OID__'+id+'__';if(dropped.data('type')=='image')insertText='![]('+url+')';else insertText='['+id+']('+url+')';let pos=codemirror.getCursor();codemirror.setSelection(pos,pos);codemirror.replaceSelection(insertText)}});codemirror.on('change',function(){let newValue=codemirror.getValue();$(textarea).val(newValue)})});$(e).find('textarea.or-editor.or-html-editor').each(function(){let textarea=this;$.trumbowyg.svgPath='./modules/editor/trumbowyg/ui/icons.svg';$(textarea).trumbowyg();$(textarea).closest('form').find('.trumbowyg-editor').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let id=dropped.data('id');let url='./?_='+dropped.data('type')+'-'+id+'&subaction=show&embed=1&__OID__'+id+'__='+id;let insertText='';if(dropped.data('type')=='image')insertText='<img src="'+url+'" alt="" />';else insertText='<a href="'+url+'" />'+id+'</a>';$(textarea).trumbowyg('execCmd',{cmd:'insertHTML',param:insertText,forceCss:!1,})}})})}); diff --git a/modules/cms/ui/themes/default/script/openrat/common.js b/modules/cms/ui/themes/default/script/openrat/common.js @@ -143,7 +143,12 @@ $( function() { }).fail(function ( jqXHR, textStatus, errorThrown ) { // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen. - console.warn( {message:'Failed to load path',url:url,error:e,status:textStatus,errorThrown } ); + console.warn( { + message:'Failed to load path', + url :url, + jqXHR :jqXHR, + status :textStatus, + error :errorThrown } ); }).always(function () { }); diff --git a/modules/cms/ui/themes/default/script/openrat/view.js b/modules/cms/ui/themes/default/script/openrat/view.js @@ -69,7 +69,7 @@ Openrat.View = function( action,method,id,params ) { if ( ! data ) data = ''; - $(element).html(data).removeClass("loader"); + $(element).html(data); $(element).find('form').each( function() { @@ -112,6 +112,10 @@ Openrat.View = function( action,method,id,params ) { notice.show(); }); + loadViewHtmlPromise.always( function() { + $(element).removeClass("loader"); + }); + // Load the data for this view. let apiUrl = Openrat.View.createUrl( this.action,this.method,this.id,this.params,true);