From dcce3335cd11d8be6fdb393e32470d9d2e49fbfd Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 1 Sep 2015 16:30:41 +0300 Subject: [PATCH] returnDispatchParams --- frontend/client/lib/bull.min.js | 4 ++-- frontend/client/src/controllers/record.js | 2 ++ frontend/client/src/views/edit.js | 2 +- frontend/client/src/views/modals/edit.js | 7 +++++++ frontend/client/src/views/record/detail.js | 12 ++++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/frontend/client/lib/bull.min.js b/frontend/client/lib/bull.min.js index e5d02f74f8..60ebb0be58 100644 --- a/frontend/client/lib/bull.min.js +++ b/frontend/client/lib/bull.min.js @@ -1,2 +1,2 @@ -/*! bull 2015-07-17 */ -var Bull=Bull||{};(function(a,b){var c=this;a.Factory=function(c){var c=c||{};this.defaultViewName=c.defaultViewName||this.defaultViewName,this._loader=c.customLoader||new a.Loader(c.resources||{}),this._renderer=c.customRenderer||new a.Renderer(c.rendering||{}),this._layouter=c.customLayouter||new a.Layouter(b.extend(c.layouting||{},{loader:this._loader})),this._templator=c.customTemplator||new a.Templator(b.extend(c.templating||{},{loader:this._loader,layouter:this._layouter})),this._helper=c.helper||null,this._viewClassHash={},this._getViewClassFunction=c.viewLoader||this._getViewClassFunction,this._viewLoader=this._getViewClassFunction},b.extend(a.Factory.prototype,{defaultViewName:"View",_layouter:null,_templator:null,_renderer:null,_loader:null,_helper:null,_viewClassHash:null,_viewLoader:null,_getViewClassFunction:function(a,b){var d=c[a];if("function"!=typeof d)throw new Error('function "'+d+'" not found.');b(d)},_getViewClass:function(a,b){return a in this._viewClassHash?void b(this._viewClassHash[a]):void this._getViewClassFunction(a,function(c){this._viewClassHash[a]=c,b(c)}.bind(this))},create:function(a,c,d){this._getViewClass(a,function(e){if("undefined"==typeof e)throw new Error('Class for view "'+a+'" not found.');new e(b.extend(c||{},{factory:this,layouter:this._layouter,templator:this._templator,renderer:this._renderer,helper:this._helper,onReady:d}))}.bind(this))}})}).call(this,Bull,_),function(a,b,c){a.View=b.View.extend({template:null,layout:null,name:null,data:null,noCache:!1,notToRender:!1,_template:null,_layout:null,layoutData:null,isReady:!1,views:null,nestedViews:null,_nestedViewDefs:null,_factory:null,factory:null,_templator:null,_renderer:null,_layouter:null,_helper:null,_templateCompiled:null,_parentView:null,_path:"",_wait:!1,expectedViews:null,optionsToPass:null,_nestedViewsFromLayoutLoaded:!1,_readyConditions:null,_rendered:!1,_isBeingRendered:!1,initialize:function(a){this.options=a||{},this._factory=this.factory=this.options.factory||null,this._renderer=this.options.renderer||null,this._templator=this.options.templator||null,this._layouter=this.options.layouter||null,this._helper=this.options.helper||null,"noCache"in this.options&&(this.noCache=this.options.noCache),this.name=this.options.name||this.name,this.notToRender="notToRender"in this.options?this.options.notToRender:this.notToRender,this.nestedViews={},this._nestedViewDefs={},null==this.expectedViews&&(this.expectedViews=[]),null==this._readyConditions&&(this._readyConditions=[]),this.optionsToPass=this.options.optionsToPass||this.optionsToPass||[],this.once("after:render",function(){this._rendered=!0},this);var b=function(a,c){for(var d in c)"object"==typeof a&&(d in a?b(a[d],c[d]):a[d]=c[d]);return a};(this.views||this.options.views)&&(this.views=b(this.options.views||{},this.views||{})),this.init(),this.setup(),this.template=this.options.template||this.template,this.layout=this.options.layout||this.layout,this._layout=this.options._layout||this._layout,this.layoutData=this.options.layoutData||this.layoutData,null!=this._template&&this._templator.compilable&&(this._templateCompiled=this._templator.compileTemplate(this._template)),this.options.el&&this.setElementInAdvance(this.options.el);var c=this._getLayout(),d=function(){this._loadNestedViews(function(){this._nestedViewsFromLayoutLoaded=!0,this._tryReady()}.bind(this))}.bind(this);return null!=this.layout||null!==c?null===c?void this._layouter.getLayout(this.layout,function(a){this._layout=a,d()}.bind(this)):void d():null!=this.views?void d():(this._nestedViewsFromLayoutLoaded=!0,void this._tryReady())},init:function(){},setup:function(){},setElementInAdvance:function(a){this.on("after:render-internal",function(){this.setElement(a)}.bind(this))},isRendered:function(){return this._rendered},isBeingRendered:function(){return this._isBeingRendered},getHtml:function(a){this._getHtml(a)},render:function(a){this._getHtml(function(b){this.$el.size()?this.$el.html(b):(this.options.el&&this.setElement(this.options.el),this.$el.html(b)),this._afterRender(),"function"==typeof a&&a()}.bind(this))},_afterRender:function(){this.trigger("after:render-internal",this);for(var a in this.nestedViews){var b=this.nestedViews[a];b.notToRender||b._afterRender()}this.afterRender(),this.trigger("after:render",this),this._isBeingRendered=!1},afterRender:function(){},_tryReady:function(){if(!this.isReady&&!this._wait&&this._nestedViewsFromLayoutLoaded){for(var a in this.expectedViews)if(!this.hasView(this.expectedViews[a]))return;for(var a in this._readyConditions)if("function"==typeof this._readyConditions[a]){if(!this._readyConditions[a]())return}else if(!this._readyConditions)return;this._makeReady()}},tryReady:function(){this._tryReady()},_makeReady:function(){this.isReady=!0,this.trigger("ready"),"function"==typeof this.options.onReady&&this.options.onReady(this)},_createViews:function(){var a=this.options.views||[];a.forEach(function(a,b){var d=c.clone(a);delete d.view,d.model=this.model,d.collection=this.collection;for(var e in this.optionsToPass){var b=this.optionsToPass[e];d[b]=this.options[b]}!d.el&&this.el&&a.selector&&(d.el=this.el+" "+a.selector),this.createView(b,a.view||null,d)}.bind(this))},_addDefinedNestedViewDefs:function(a){for(var b in this.views){var d=c.clone(this.views[b]);d.name=b,a.push(d),this._nestedViewDefs[b]=d}return a},_getNestedViewsFromLayout:function(){var a=this._layouter.findNestedViews(this._getLayoutName(),this._getLayout()||null,this.noCache);if("[object Array]"!==Object.prototype.toString.call(a))throw new Error("Bad layout. It should be an Array.");var b=[];for(var c in a){var d=a[c].name;this._nestedViewDefs[d]=a[c],(!("view"in a[c]&&a[c].view===!0)||"layout"in a[c]||"template"in a[c])&&b.push(a[c])}return b},_loadNestedViews:function(a){var b=[];null!=this._layout&&(b=this._getNestedViewsFromLayout()),this._addDefinedNestedViewDefs(b);var d=b.length,e=0,f=function(){return e==d?(a(),!0):void 0};f(),b.forEach(function(a,d){var g=b[d].name,h=this._factory.defaultViewName;if("view"in b[d]&&(h=b[d].view),h===!1)e++,f();else{var i={};"layout"in b[d]&&(i.layout=b[d].layout),"template"in b[d]&&(i.template=b[d].template),"el"in b[d]&&(i.el=b[d].el),"options"in b[d]&&(i=c.extend(i,b[d].options)),this.model&&(i.model=this.model),this.collection&&(i.collection=this.collection);for(var d in this.optionsToPass){var j=this.optionsToPass[d];i[j]=this.options[j]}this._factory.create(h,i,function(a){"notToRender"in b[d]&&(a.notToRender=b[d].notToRender),this.setView(g,a),e++,f()}.bind(this))}},this)},_getData:function(){return"function"==typeof this.data?this.data():this.data},_getNestedViewsAsArray:function(a){var b=[],c=0;for(var d in this.nestedViews)b.push({key:d,view:this.nestedViews[d]}),c++;return b},_getNestedViewsHtmlList:function(a){var b={},c=this._getNestedViewsAsArray(),d=0,e=c.length,f=function(){return d==e?(a(b),!0):void 0};f(),c.forEach(function(a,e){var g=c[e].key,h=c[e].view;h.notToRender?(d++,f()):h.getHtml(function(a){b[g]=a,d++,f()})},this)},_getHtml:function(a){this._isBeingRendered=!0,this.trigger("render",this),this._getNestedViewsHtmlList(function(b){var d=c.extend(this._getData()||{},b);this.collection&&(d.collection=this.collection),this.model&&(d.model=this.model),this._getTemplate(function(b){var c=this._renderer.render(b,d);a(c)}.bind(this))}.bind(this))},_getTemplateName:function(){return this.template||null},_getLayoutName:function(){return this.layout||this.name||null},_getLayoutData:function(){return this.layoutData},_getLayout:function(){return"function"==typeof this._layout?this._layout():this._layout},_getTemplate:function(a){if(this._templator.compilable&&null!==this._templateCompiled)return void a(this._templateCompiled);var b=this._template||null;if(null!==b)return void a(b);var c=this._getTemplateName(),d=!1,e={};if(!c){d=this.noCache;var f=this._getLayoutName();f?c=f?"built-"+f:null:d=!0,e={name:f,data:this._getLayoutData(),layout:this._getLayout()}}this._templator.getTemplate(c,e,d,a)},_updatePath:function(a,b){this._path=a+"/"+b;for(var c in this.nestedViews)this.nestedViews[c]._updatePath(this._path,c)},_getSelectorForNestedView:function(a){var b=!1;if(a in this._nestedViewDefs)if("id"in this._nestedViewDefs[a])b="#"+this._nestedViewDefs[a].id;else if("el"in this._nestedViewDefs[a])b=this._nestedViewDefs[a].el;else if("selector"in this._nestedViewDefs[a]){var c=null;c="object"==typeof this.el?this.$el.selector:this.options.el||this.el,c&&(b=c+" "+this._nestedViewDefs[a].selector)}return b},hasView:function(a){return a in this.nestedViews?!0:!1},getView:function(a){return a in this.nestedViews?this.nestedViews[a]:void 0},createView:function(a,b,c,d,e){e="undefined"==typeof e?!0:e;var f=this;e&&this.waitForView(a),this._factory.create(b,c,function(b){this._rendered&&this.setView(a,b),"function"==typeof d&&d.call(f,b),this._rendered||this.setView(a,b)}.bind(this))},setView:function(a,b,c){var c=c||this._getSelectorForNestedView(a)||b.options.el||!1;c&&(this.isRendered()?b.setElement(c):b.setElementInAdvance(c)),a in this.nestedViews&&this.clearView(a),this.nestedViews[a]=b,b._parentView=this,b._updatePath(this._path,a),this._tryReady()},clearView:function(a){a in this.nestedViews&&(this.nestedViews[a].remove(),delete this.nestedViews[a])},getParentView:function(){return this._parentView},addReadyCondition:function(a){this._readyConditions.push(a)},waitForView:function(a){this.expectedViews.push(a)},wait:function(a){a?this._wait=!0:(this._wait=!1,this._tryReady())},remove:function(){for(var a in this.nestedViews)this.clearView(a);return this.trigger("remove"),this.off(),this.$el.empty(),this.stopListening(),this.undelegateEvents(),this.model&&this.model.off(null,null,this),this.collection&&this.collection.off(null,null,this),this}})}.call(this,Bull,Backbone,_),function(a,b){a.Loader=function(a){var a=a||{};this._paths=b.extend(this._paths,a.paths||{}),this._exts=b.extend(this._exts,a.exts||{}),this._normalize=b.extend(this._normalize,a.normalize||{}),this._isJson=b.extend(this._isJson,a.isJson||{}),this._externalLoaders=b.extend(this._externalLoaders,a.loaders||{}),this._externalPathFunction=a.path||null},b.extend(a.Loader.prototype,{_exts:{layout:"json",template:"tpl",layoutTemplate:"tpl"},_paths:{layout:"layouts",template:"templates",layoutTemplate:"templates/layouts"},_isJson:{layout:!0},_externalLoaders:{layout:null,template:null,layoutTemplate:null},_externalPathFunction:null,_normalize:{layouts:function(a){return a},templates:function(a){return a},layoutTemplates:function(a){return a}},getFilePath:function(a,b){if(!(a in this._paths&&a in this._exts))throw new TypeError('Unknown resource type "'+a+'" requested in Bull.Loader.');var c=b;a in this._normalize&&(c=this._normalize[a](b));var d=this._paths[a];return"/"==d.substr(-1)&&(d=d.substr(0,d.length-1)),d+"/"+c+"."+this._exts[a]},_callExternalLoader:function(a,b,c){if(a in this._externalLoaders&&null!==this._externalLoaders[a]){if("function"==typeof this._externalLoaders[a])return this._externalLoaders[a](b,c),!0;throw new Error('Loader for "'+a+'" in not a Function.')}return null},load:function(a,b,c){var d=this._callExternalLoader(a,b,c);if(!d){var e,f;f=null!=this._externalPathFunction?this._externalPathFunction.call(this,a,b):this.getFilePath(a,b),f+="?_="+(new Date).getTime();var g=new XMLHttpRequest;g.open("GET",f,!0),g.setRequestHeader("X-Requested-With","XMLHttpRequest"),g.onreadystatechange=function(){if(4===g.readyState){if(e=g.responseText,a in this._isJson&&this._isJson[a]){var d;if(404==g.status||403==g.status)throw new Error("Could not load "+a+' "'+b+'".');try{d=JSON.parse(String(e))}catch(f){throw new SyntaxError("Error while parsing "+a+' "'+b+'": ('+f.message+").")}return void c(d)}c(e)}}.bind(this),g.send(null)}}})}.call(this,Bull,_),function(a,b,c){a.Templator=function(a){var a=a||{};this._templates={},this._layoutTemplates={},this._loader=a.loader||null,this._layouter=a.layouter||null,"compilable"in a&&(this.compilable=a.compilable)},b.extend(a.Templator.prototype,{compilable:!0,_templates:null,_layoutTemplates:null,_loader:null,_layouter:null,addTemplate:function(a,b){this._templates[a]=b},getTemplate:function(a,b,c,d){var b=b||{},e=null;if(!b.name&&!b.layout&&!a)throw new Error("Can not get template. Not enough data passed.");if(!c&&a&&(e=this._getCachedTemplate(a)))return void d(e);var f=b.layout||null,g=function(b){this.compilable&&(b=this.compileTemplate(b)),this._templates[a]=b,d(b)}.bind(this),h=function(a){if(null==a)throw new Error("Could not get layout '"+b.name+"'.");this._buildTemplate(a,b.data,g)}.bind(this);e||(b.name||b.layout?f?h(f):this._layouter.getLayout(b.name,h):this._loader.load("template",a,g))},compileTemplate:function(a){return"undefined"!=typeof c?c.compile(a):a},_getCachedTemplate:function(a){return a in this._templates?this._templates[a]:!1},_getCachedLayoutTemplate:function(a){return a in this._layoutTemplates?this._layoutTemplates[a]:!1},_cacheLayoutTemplate:function(a,b){this._layoutTemplates[a]=b},_buildTemplate:function(a,c,d){var e=a.type||"default",f=function(e){var f=b.extend(a,c||{});d(b.template(e,f))}.bind(this),g=this._getCachedLayoutTemplate(e);return g?void f(g):void this._loader.load("layoutTemplate",e,function(a){this._cacheLayoutTemplate(e,a),f(a)}.bind(this))}})}.call(this,Bull,_,Handlebars),function(a,b){a.Layouter=function(a){var a=a||{};this._layouts={},this._loader=a.loader||null,this._cachedNestedViews={}},b.extend(a.Layouter.prototype,{_layouts:null,_loader:null,_cachedNestedViews:null,addLayout:function(a,b){this._layouts[a]=b},getLayout:function(a,b){return a in this._layouts?void b(this._layouts[a]):layout?void 0:void this._loader.load("layout",a,function(c){this.addLayout(a,c),b(c)}.bind(this))},_getCachedNestedViews:function(a){return a in this._cachedNestedViews?this._cachedNestedViews[a]:!1},_cacheNestedViews:function(a,b){a in this._cachedNestedViews||(this._cachedNestedViews[a]=b)},findNestedViews:function(a,b,c){if(!a&&!b)throw new Error("Can not find nested views. No layout data and name.");if(a&&!c){var d=this._getCachedNestedViews(a);if(d)return d}if("undefined"==typeof b&&(a in this._layouts&&(b=this._layouts[a]),!("layout"in b)))throw new Error('Layout "'+a+'" is bad.');var e=b.layout,f=[],g=function(a,b){var c=a;if("undefined"!=typeof b)c=c+"_"+b;else var b=0;for(var d in f)if(f[d].name==c)return g(a,b+1);return c},h=function(a){var b={},c=["view","layout","notToRender","options","template","id","selector","el"];for(var d in c){var e=c[d];e in a&&(b[e]=a[e])}return"name"in a&&(b.name=g(a.name)),b},i=function(a){for(var b in a)if(null!=a[b]&&"object"==typeof a[b])if("view"in a[b]||"layout"in a[b]||"template"in a[b]){var c=h(a[b]);"name"in c&&f.push(c)}else i(a[b])};return i(e),a&&!c&&this._cacheNestedViews(a,f),f}})}.call(this,Bull,_),function(a,b){a.Renderer=function(a){var a=a||{};this._render=a.method||this._render},b.extend(a.Renderer.prototype,{_render:function(a,b){return a(b)},render:function(a,b){return this._render.call(this,a,b)}})}.call(this,Bull,_); \ No newline at end of file +/*! bull 2015-09-01 */ +var Bull=Bull||{};(function(a,b){var c=this;a.Factory=function(c){var c=c||{};this.defaultViewName=c.defaultViewName||this.defaultViewName,this._loader=c.customLoader||new a.Loader(c.resources||{}),this._renderer=c.customRenderer||new a.Renderer(c.rendering||{}),this._layouter=c.customLayouter||new a.Layouter(b.extend(c.layouting||{},{loader:this._loader})),this._templator=c.customTemplator||new a.Templator(b.extend(c.templating||{},{loader:this._loader,layouter:this._layouter})),this._helper=c.helper||null,this._viewClassHash={},this._getViewClassFunction=c.viewLoader||this._getViewClassFunction,this._viewLoader=this._getViewClassFunction},b.extend(a.Factory.prototype,{defaultViewName:"View",_layouter:null,_templator:null,_renderer:null,_loader:null,_helper:null,_viewClassHash:null,_viewLoader:null,_getViewClassFunction:function(a,b){var d=c[a];if("function"!=typeof d)throw new Error('function "'+d+'" not found.');b(d)},_getViewClass:function(a,b){return a in this._viewClassHash?void b(this._viewClassHash[a]):void this._getViewClassFunction(a,function(c){this._viewClassHash[a]=c,b(c)}.bind(this))},create:function(a,c,d){this._getViewClass(a,function(e){if("undefined"==typeof e)throw new Error('Class for view "'+a+'" not found.');new e(b.extend(c||{},{factory:this,layouter:this._layouter,templator:this._templator,renderer:this._renderer,helper:this._helper,onReady:d}))}.bind(this))}})}).call(this,Bull,_),function(a,b,c){a.View=b.View.extend({template:null,layout:null,name:null,data:null,noCache:!1,notToRender:!1,_template:null,_layout:null,layoutData:null,isReady:!1,views:null,nestedViews:null,_nestedViewDefs:null,_factory:null,factory:null,_templator:null,_renderer:null,_layouter:null,_helper:null,_templateCompiled:null,_parentView:null,_path:"",_wait:!1,expectedViews:null,optionsToPass:null,_nestedViewsFromLayoutLoaded:!1,_readyConditions:null,_rendered:!1,_isBeingRendered:!1,initialize:function(a){this.options=a||{},this._factory=this.factory=this.options.factory||null,this._renderer=this.options.renderer||null,this._templator=this.options.templator||null,this._layouter=this.options.layouter||null,this._helper=this.options.helper||null,"noCache"in this.options&&(this.noCache=this.options.noCache),this.name=this.options.name||this.name,this.notToRender="notToRender"in this.options?this.options.notToRender:this.notToRender,this.nestedViews={},this._nestedViewDefs={},null==this.expectedViews&&(this.expectedViews=[]),null==this._readyConditions&&(this._readyConditions=[]),this.optionsToPass=this.options.optionsToPass||this.optionsToPass||[],this.once("after:render",function(){this._rendered=!0},this);var b=function(a,c){for(var d in c)"object"==typeof a&&(d in a?b(a[d],c[d]):a[d]=c[d]);return a};(this.views||this.options.views)&&(this.views=b(this.options.views||{},this.views||{})),this.init(),this.setup(),this.template=this.options.template||this.template,this.layout=this.options.layout||this.layout,this._layout=this.options._layout||this._layout,this.layoutData=this.options.layoutData||this.layoutData,null!=this._template&&this._templator.compilable&&(this._templateCompiled=this._templator.compileTemplate(this._template)),this.options.el&&this.setElementInAdvance(this.options.el);var c=this._getLayout(),d=function(){this._loadNestedViews(function(){this._nestedViewsFromLayoutLoaded=!0,this._tryReady()}.bind(this))}.bind(this);return null!=this.layout||null!==c?null===c?void this._layouter.getLayout(this.layout,function(a){this._layout=a,d()}.bind(this)):void d():null!=this.views?void d():(this._nestedViewsFromLayoutLoaded=!0,void this._tryReady())},init:function(){},setup:function(){},setElementInAdvance:function(a){this.on("after:render-internal",function(){this.setElement(a)}.bind(this))},isRendered:function(){return this._rendered},isBeingRendered:function(){return this._isBeingRendered},getHtml:function(a){this._getHtml(a)},render:function(a){this._getHtml(function(b){this.$el.size()?this.$el.html(b):(this.options.el&&this.setElement(this.options.el),this.$el.html(b)),this._afterRender(),"function"==typeof a&&a()}.bind(this))},_afterRender:function(){this.trigger("after:render-internal",this);for(var a in this.nestedViews){var b=this.nestedViews[a];b.notToRender||b._afterRender()}this.afterRender(),this.trigger("after:render",this),this._isBeingRendered=!1},afterRender:function(){},_tryReady:function(){if(!this.isReady&&!this._wait&&this._nestedViewsFromLayoutLoaded){for(var a in this.expectedViews)if(!this.hasView(this.expectedViews[a]))return;for(var a in this._readyConditions)if("function"==typeof this._readyConditions[a]){if(!this._readyConditions[a]())return}else if(!this._readyConditions)return;this._makeReady()}},tryReady:function(){this._tryReady()},_makeReady:function(){this.isReady=!0,this.trigger("ready"),"function"==typeof this.options.onReady&&this.options.onReady(this)},_createViews:function(){var a=this.options.views||[];a.forEach(function(a,b){var d=c.clone(a);delete d.view,d.model=this.model,d.collection=this.collection;for(var e in this.optionsToPass){var b=this.optionsToPass[e];d[b]=this.options[b]}!d.el&&this.el&&a.selector&&(d.el=this.el+" "+a.selector),this.createView(b,a.view||null,d)}.bind(this))},_addDefinedNestedViewDefs:function(a){for(var b in this.views){var d=c.clone(this.views[b]);d.name=b,a.push(d),this._nestedViewDefs[b]=d}return a},_getNestedViewsFromLayout:function(){var a=this._layouter.findNestedViews(this._getLayoutName(),this._getLayout()||null,this.noCache);if("[object Array]"!==Object.prototype.toString.call(a))throw new Error("Bad layout. It should be an Array.");var b=[];for(var c in a){var d=a[c].name;this._nestedViewDefs[d]=a[c],(!("view"in a[c]&&a[c].view===!0)||"layout"in a[c]||"template"in a[c])&&b.push(a[c])}return b},_loadNestedViews:function(a){var b=[];null!=this._layout&&(b=this._getNestedViewsFromLayout()),this._addDefinedNestedViewDefs(b);var d=b.length,e=0,f=function(){return e==d?(a(),!0):void 0};f(),b.forEach(function(a,d){var g=b[d].name,h=this._factory.defaultViewName;if("view"in b[d]&&(h=b[d].view),h===!1)e++,f();else{var i={};"layout"in b[d]&&(i.layout=b[d].layout),"template"in b[d]&&(i.template=b[d].template),"el"in b[d]&&(i.el=b[d].el),"options"in b[d]&&(i=c.extend(i,b[d].options)),this.model&&(i.model=this.model),this.collection&&(i.collection=this.collection);for(var j in this.optionsToPass){var k=this.optionsToPass[j];i[k]=this.options[k]}this._factory.create(h,i,function(a){"notToRender"in b[d]&&(a.notToRender=b[d].notToRender),this.setView(g,a),e++,f()}.bind(this))}},this)},_getData:function(){return"function"==typeof this.data?this.data():this.data},_getNestedViewsAsArray:function(a){var b=[],c=0;for(var d in this.nestedViews)b.push({key:d,view:this.nestedViews[d]}),c++;return b},_getNestedViewsHtmlList:function(a){var b={},c=this._getNestedViewsAsArray(),d=0,e=c.length,f=function(){return d==e?(a(b),!0):void 0};f(),c.forEach(function(a,e){var g=c[e].key,h=c[e].view;h.notToRender?(d++,f()):h.getHtml(function(a){b[g]=a,d++,f()})},this)},_getHtml:function(a){this._isBeingRendered=!0,this.trigger("render",this),this._getNestedViewsHtmlList(function(b){var d=c.extend(this._getData()||{},b);this.collection&&(d.collection=this.collection),this.model&&(d.model=this.model),this._getTemplate(function(b){var c=this._renderer.render(b,d);a(c)}.bind(this))}.bind(this))},_getTemplateName:function(){return this.template||null},_getLayoutName:function(){return this.layout||this.name||null},_getLayoutData:function(){return this.layoutData},_getLayout:function(){return"function"==typeof this._layout?this._layout():this._layout},_getTemplate:function(a){if(this._templator.compilable&&null!==this._templateCompiled)return void a(this._templateCompiled);var b=this._template||null;if(null!==b)return void a(b);var c=this._getTemplateName(),d=!1,e={};if(!c){d=this.noCache;var f=this._getLayoutName();f?c=f?"built-"+f:null:d=!0,e={name:f,data:this._getLayoutData(),layout:this._getLayout()}}this._templator.getTemplate(c,e,d,a)},_updatePath:function(a,b){this._path=a+"/"+b;for(var c in this.nestedViews)this.nestedViews[c]._updatePath(this._path,c)},_getSelectorForNestedView:function(a){var b=!1;if(a in this._nestedViewDefs)if("id"in this._nestedViewDefs[a])b="#"+this._nestedViewDefs[a].id;else if("el"in this._nestedViewDefs[a])b=this._nestedViewDefs[a].el;else if("selector"in this._nestedViewDefs[a]){var c=null;c="object"==typeof this.el?this.$el.selector:this.options.el||this.el,c&&(b=c+" "+this._nestedViewDefs[a].selector)}return b},hasView:function(a){return a in this.nestedViews?!0:!1},getView:function(a){return a in this.nestedViews?this.nestedViews[a]:void 0},createView:function(a,b,c,d,e){e="undefined"==typeof e?!0:e;var f=this;e&&this.waitForView(a),this._factory.create(b,c,function(b){this._rendered&&this.setView(a,b),"function"==typeof d&&d.call(f,b),this._rendered||this.setView(a,b)}.bind(this))},setView:function(a,b,c){var c=c||this._getSelectorForNestedView(a)||b.options.el||!1;c&&(this.isRendered()?b.setElement(c):b.setElementInAdvance(c)),a in this.nestedViews&&this.clearView(a),this.nestedViews[a]=b,b._parentView=this,b._updatePath(this._path,a),this._tryReady()},clearView:function(a){a in this.nestedViews&&(this.nestedViews[a].remove(),delete this.nestedViews[a])},getParentView:function(){return this._parentView},addReadyCondition:function(a){this._readyConditions.push(a)},waitForView:function(a){this.expectedViews.push(a)},wait:function(a){a?this._wait=!0:(this._wait=!1,this._tryReady())},remove:function(){for(var a in this.nestedViews)this.clearView(a);return this.trigger("remove"),this.off(),this.$el.empty(),this.stopListening(),this.undelegateEvents(),this.model&&this.model.off(null,null,this),this.collection&&this.collection.off(null,null,this),this}})}.call(this,Bull,Backbone,_),function(a,b){a.Loader=function(a){var a=a||{};this._paths=b.extend(this._paths,a.paths||{}),this._exts=b.extend(this._exts,a.exts||{}),this._normalize=b.extend(this._normalize,a.normalize||{}),this._isJson=b.extend(this._isJson,a.isJson||{}),this._externalLoaders=b.extend(this._externalLoaders,a.loaders||{}),this._externalPathFunction=a.path||null},b.extend(a.Loader.prototype,{_exts:{layout:"json",template:"tpl",layoutTemplate:"tpl"},_paths:{layout:"layouts",template:"templates",layoutTemplate:"templates/layouts"},_isJson:{layout:!0},_externalLoaders:{layout:null,template:null,layoutTemplate:null},_externalPathFunction:null,_normalize:{layouts:function(a){return a},templates:function(a){return a},layoutTemplates:function(a){return a}},getFilePath:function(a,b){if(!(a in this._paths&&a in this._exts))throw new TypeError('Unknown resource type "'+a+'" requested in Bull.Loader.');var c=b;a in this._normalize&&(c=this._normalize[a](b));var d=this._paths[a];return"/"==d.substr(-1)&&(d=d.substr(0,d.length-1)),d+"/"+c+"."+this._exts[a]},_callExternalLoader:function(a,b,c){if(a in this._externalLoaders&&null!==this._externalLoaders[a]){if("function"==typeof this._externalLoaders[a])return this._externalLoaders[a](b,c),!0;throw new Error('Loader for "'+a+'" in not a Function.')}return null},load:function(a,b,c){var d=this._callExternalLoader(a,b,c);if(!d){var e,f;f=null!=this._externalPathFunction?this._externalPathFunction.call(this,a,b):this.getFilePath(a,b),f+="?_="+(new Date).getTime();var g=new XMLHttpRequest;g.open("GET",f,!0),g.setRequestHeader("X-Requested-With","XMLHttpRequest"),g.onreadystatechange=function(){if(4===g.readyState){if(e=g.responseText,a in this._isJson&&this._isJson[a]){var d;if(404==g.status||403==g.status)throw new Error("Could not load "+a+' "'+b+'".');try{d=JSON.parse(String(e))}catch(f){throw new SyntaxError("Error while parsing "+a+' "'+b+'": ('+f.message+").")}return void c(d)}c(e)}}.bind(this),g.send(null)}}})}.call(this,Bull,_),function(a,b,c){a.Templator=function(a){var a=a||{};this._templates={},this._layoutTemplates={},this._loader=a.loader||null,this._layouter=a.layouter||null,"compilable"in a&&(this.compilable=a.compilable)},b.extend(a.Templator.prototype,{compilable:!0,_templates:null,_layoutTemplates:null,_loader:null,_layouter:null,addTemplate:function(a,b){this._templates[a]=b},getTemplate:function(a,b,c,d){var b=b||{},e=null;if(!b.name&&!b.layout&&!a)throw new Error("Can not get template. Not enough data passed.");if(!c&&a&&(e=this._getCachedTemplate(a)))return void d(e);var f=b.layout||null,g=function(b){this.compilable&&(b=this.compileTemplate(b)),this._templates[a]=b,d(b)}.bind(this),h=function(a){if(null==a)throw new Error("Could not get layout '"+b.name+"'.");this._buildTemplate(a,b.data,g)}.bind(this);e||(b.name||b.layout?f?h(f):this._layouter.getLayout(b.name,h):this._loader.load("template",a,g))},compileTemplate:function(a){return"undefined"!=typeof c?c.compile(a):a},_getCachedTemplate:function(a){return a in this._templates?this._templates[a]:!1},_getCachedLayoutTemplate:function(a){return a in this._layoutTemplates?this._layoutTemplates[a]:!1},_cacheLayoutTemplate:function(a,b){this._layoutTemplates[a]=b},_buildTemplate:function(a,c,d){var e=a.type||"default",f=function(e){var f=b.extend(a,c||{});d(b.template(e,f))}.bind(this),g=this._getCachedLayoutTemplate(e);return g?void f(g):void this._loader.load("layoutTemplate",e,function(a){this._cacheLayoutTemplate(e,a),f(a)}.bind(this))}})}.call(this,Bull,_,Handlebars),function(a,b){a.Layouter=function(a){var a=a||{};this._layouts={},this._loader=a.loader||null,this._cachedNestedViews={}},b.extend(a.Layouter.prototype,{_layouts:null,_loader:null,_cachedNestedViews:null,addLayout:function(a,b){this._layouts[a]=b},getLayout:function(a,b){return a in this._layouts?void b(this._layouts[a]):layout?void 0:void this._loader.load("layout",a,function(c){this.addLayout(a,c),b(c)}.bind(this))},_getCachedNestedViews:function(a){return a in this._cachedNestedViews?this._cachedNestedViews[a]:!1},_cacheNestedViews:function(a,b){a in this._cachedNestedViews||(this._cachedNestedViews[a]=b)},findNestedViews:function(a,b,c){if(!a&&!b)throw new Error("Can not find nested views. No layout data and name.");if(a&&!c){var d=this._getCachedNestedViews(a);if(d)return d}if("undefined"==typeof b&&(a in this._layouts&&(b=this._layouts[a]),!("layout"in b)))throw new Error('Layout "'+a+'" is bad.');var e=b.layout,f=[],g=function(a,b){var c=a;if("undefined"!=typeof b)c=c+"_"+b;else var b=0;for(var d in f)if(f[d].name==c)return g(a,b+1);return c},h=function(a){var b={},c=["view","layout","notToRender","options","template","id","selector","el"];for(var d in c){var e=c[d];e in a&&(b[e]=a[e])}return"name"in a&&(b.name=g(a.name)),b},i=function(a){for(var b in a)if(null!=a[b]&&"object"==typeof a[b])if("view"in a[b]||"layout"in a[b]||"template"in a[b]){var c=h(a[b]);"name"in c&&f.push(c)}else i(a[b])};return i(e),a&&!c&&this._cacheNestedViews(a,f),f}})}.call(this,Bull,_),function(a,b){a.Renderer=function(a){var a=a||{};this._render=a.method||this._render},b.extend(a.Renderer.prototype,{_render:function(a,b){return a(b)},render:function(a,b){return this._render.call(this,a,b)}})}.call(this,Bull,_); \ No newline at end of file diff --git a/frontend/client/src/controllers/record.js b/frontend/client/src/controllers/record.js index d6b176b3ed..0ecf2b2370 100644 --- a/frontend/client/src/controllers/record.js +++ b/frontend/client/src/controllers/record.js @@ -136,6 +136,7 @@ Espo.define('controllers/record', 'controller', function (Dep) { scope: this.name, model: model, returnUrl: options.returnUrl, + returnDispatchParams: options.returnDispatchParams, views: this.getViews('edit'), }; @@ -163,6 +164,7 @@ Espo.define('controllers/record', 'controller', function (Dep) { scope: this.name, model: model, returnUrl: options.returnUrl, + returnDispatchParams: options.returnDispatchParams, views: this.getViews('edit'), }; diff --git a/frontend/client/src/views/edit.js b/frontend/client/src/views/edit.js index 5fcfa52337..609daefb96 100644 --- a/frontend/client/src/views/edit.js +++ b/frontend/client/src/views/edit.js @@ -33,7 +33,7 @@ Espo.define('views/edit', 'views/main', function (Dep) { menu: null, - optionsToPass: ['returnUrl', 'attributes'], + optionsToPass: ['returnUrl', 'returnDispatchParams', 'attributes'], views: { header: { diff --git a/frontend/client/src/views/modals/edit.js b/frontend/client/src/views/modals/edit.js index c7738e5f3a..a75c978a91 100644 --- a/frontend/client/src/views/modals/edit.js +++ b/frontend/client/src/views/modals/edit.js @@ -176,6 +176,13 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { router.dispatch(this.scope, 'edit', { attributes: attributes, returnUrl: Backbone.history.fragment, + returnDispatchParams: { + controller: this.scope, + action: null, + options: { + isReturn: true + } + }, id: this.id }); router.navigate(url, {trigger: false}); diff --git a/frontend/client/src/views/record/detail.js b/frontend/client/src/views/record/detail.js index 6afd895fdd..94b7be18f2 100644 --- a/frontend/client/src/views/record/detail.js +++ b/frontend/client/src/views/record/detail.js @@ -80,6 +80,8 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) { returnUrl: null, + returnDispatchParams: null, + sideView: 'Record.DetailSide', bottomView: 'Record.DetailBottom', @@ -348,6 +350,8 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) { this.dropdownEditItemList = _.clone(this.dropdownEditItemList); this.returnUrl = this.options.returnUrl || this.returnUrl; + this.returnDispatchParams = this.options.returnDispatchParams || this.returnDispatchParams; + this.exit = this.options.exit || this.exit; this.columnCount = this.options.columnCount || this.columnCount; @@ -680,6 +684,14 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) { url += '/view/' + this.model.id; } } + if (this.returnDispatchParams) { + var controller = this.returnDispatchParams.controller; + var action = this.returnDispatchParams.action; + var options = this.returnDispatchParams.options || {}; + this.getRouter().dispatch(controller, action, options); + this.getRouter().navigate(url, {trigger: false}); + return; + } this.getRouter().navigate(url, {trigger: true}); },