class RouterConstructor{constructor(views,components_templates,custom_components_templates){this.views=views;this.components_templates=components_templates;this.custom_components_templates=custom_components_templates;this.routes=[];}
getRouteComponent(view){return{mixins:this.getRouteComponentMixins(view),template:view.template,data:function(){return{view:view,};},};}
getRouteComponentMixins(view){return[this.components_templates.base,this.components_templates[view.schema.type],].concat(view.mixins||[]);}
getRoutes(){this.routes=this.formAllRoutes();return this.routes;}
formAllRoutes(){let routes=[{name:'home',path:'/',component:this.custom_components_templates.home||{},}];this.emitSignalAboutRouteCreation(routes.last);routes=routes.concat(this.formRoutesBasedOnViews(),this.formRoutesBasedOnCustomComponents(),{name:'404',path:'*',component:this.custom_components_templates['404']||{},},);this.emitSignalAboutRouteCreation(routes.last);tabSignal.emit('allRoutes.created',routes);return routes;}
formRoutesBasedOnViews(){let routes=[];for(let path in this.views){if(!this.views.hasOwnProperty(path)){continue;}
routes.push({name:path,path:this.views[path].getPathTemplateForRouter(path),component:this.getRouteComponent(this.views[path]),});this.emitSignalAboutRouteCreation(routes.last);}
return routes;}
formRoutesBasedOnCustomComponents(){let routes=[];for(let item in this.custom_components_templates){if(!this.custom_components_templates.hasOwnProperty(item)){continue;}
if(['home','404'].includes(item)){continue;}
let path_template=item.replace(/\{/g,":").replace(/\}/g,"");if(this.custom_components_templates[item].getPathTemplateForRouter&&typeof this.custom_components_templates[item].getPathTemplateForRouter==='function'){path_template=this.custom_components_templates[item].getPathTemplateForRouter(item);}
routes.push({name:item,path:path_template,component:this.custom_components_templates[item],});this.emitSignalAboutRouteCreation(routes.last);}
return routes;}
emitSignalAboutRouteCreation(route){tabSignal.emit('routes['+route.name+'].created',route);}
getRouter(){return new VueRouter({routes:this.getRoutes(),});}}
const the_basest_view_mixin={data(){return{loading:false,error:null,response:null,};},created(){this.setDocumentTitle();},watch:{title(){this.setDocumentTitle();},},computed:{title(){return'Default title';},},methods:{goToHistoryRecord(n){this.$router.go(n);},setDocumentTitle(){let title=this.$options.filters.capitalize(this.title);title=this.$options.filters.split(title);document.title=title;},initLoading(){this.error=this.response=null;this.loading=true;current_view.initLoading();},setLoadingSuccessful(){this.loading=false;this.response=true;current_view.setLoadingSuccessful();},setLoadingError(error){this.loading=false;this.error=error;current_view.setLoadingError(error);},},};const page_with_data_mixin={computed:{title:function(){try{return this.data.instance.getViewFieldValue()||this.view.schema.name;}catch(e){return this.view.schema.name;}},},methods:{removeInstance(){let instance=this.data.instance;instance.delete().then(response=>{guiPopUp.success(pop_up_msg.instance.success.remove.format([instance.getViewFieldValue()||instance.getPkValue(),this.view.schema.name]));this.deleteQuerySet(this.qs_url);this.deleteQuerySetFromSandBox(this.qs_url);this.openRedirectUrl({path:this.getRedirectUrl()});}).catch(error=>{let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.remove.format([instance.getViewFieldValue()||instance.getPkValue(),this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);debugger;});},getRedirectUrl(opt){return this.url.replace("/edit","").replace("/new","").split("/").slice(0,-1).join("/");},},};const editable_page_mixin={methods:{setQuerySetInSandBox(view,url){let page_view=view;try{page_view=this.$store.getters.getViews[view.schema.path.replace('/edit','')];}catch(e){}
let qs=this.getQuerySet(page_view,url);let sandbox_qs;if(qs.model.name==view.objects.model.name){sandbox_qs=qs.copy();}else{sandbox_qs=view.objects.clone({use_prefetch:true,url:url.replace(/^\/|\/$/g,""),});}
this.$store.commit('setQuerySetInSandBox',{url:sandbox_qs.url,queryset:sandbox_qs,});},getQuerySetFromSandBox(view,url){let qs=this.$store.getters.getQuerySetFromSandBox(url.replace(/^\/|\/$/g,""));if(!qs){this.setQuerySetInSandBox(view,url);return this.$store.getters.getQuerySetFromSandBox(url.replace(/^\/|\/$/g,""));}
return qs;},setAndGetQuerySetFromSandBox(view,url){this.setQuerySetInSandBox(view,url);return this.$store.getters.getQuerySetFromSandBox(url.replace(/^\/|\/$/g,""));},setAndGetInstanceFromSandBox(view,url){return this.setAndGetQuerySetFromSandBox(view,url).get();},getValidData(){try{let valid_data={};let url=this.qs_url.replace(/^\/|\/$/g,"");let data=$.extend(true,{},this.$store.getters.getViewInstanceData({store:'sandbox',url:url,}));let toInnerData={};for(let key in this.data.instance.fields){if(this.data.instance.fields.hasOwnProperty(key)){let field=this.data.instance.fields[key];toInnerData[key]=field.toInner(data);}}
for(let key in this.data.instance.fields){if(this.data.instance.fields.hasOwnProperty(key)){let field=this.data.instance.fields[key];if(field.options.readOnly){continue;}
let value=field.validateValue(toInnerData);if(value!==undefined&&value!==null){valid_data[key]=value;}}}
if(this.getValidDataAdditional){valid_data=this.getValidDataAdditional(valid_data);}
return valid_data;}catch(e){app.error_handler.defineErrorAndShow(e);}},}};const view_with_autoupdate_mixin={data(){return{autoupdate:{timeout_id:undefined,stop:false,},};},beforeRouteUpdate(to,from,next){this.stopAutoUpdate();next();},beforeRouteLeave(to,from,next){this.stopAutoUpdate();this.$destroy();next();},methods:{getAutoUpdateInterval(){return guiLocalSettings.get('page_update_interval')||5000;},startAutoUpdate(){let update_interval=this.getAutoUpdateInterval();this.autoupdate.stop=false;if(Visibility.state()=='hidden'){return setTimeout(()=>{this.startAutoUpdate();},update_interval);}
this.autoupdate.timeout_id=setTimeout(()=>{this.updateData().then(response=>{if(!this.autoupdate.stop){this.startAutoUpdate();}});},update_interval);},stopAutoUpdate(){this.autoupdate.stop=true;clearTimeout(this.autoupdate.timeout_id);},updateData(){let qs=this.getQuerySet(this.view,this.qs_url);let new_qs=this.getQuerySet(this.view,this.qs_url).clone();return new_qs.get().then(instance=>{if(qs.cache.getPkValue()==instance.getPkValue()){for(let key in instance.data){if(instance.data.hasOwnProperty(key)){if(!deepEqual(instance.data[key],qs.cache.data[key])){qs.cache.data[key]=instance.data[key];}}}
qs.cache.data={...qs.cache.data};}
return true;}).catch(error=>{debugger;});},}};const collapsable_card_mixin={data(){return{card_collapsed:false,card_collapsed_button:false,};},methods:{toggleCardCollapsed(){this.card_collapsed=!this.card_collapsed;},},};let list_props={page_size:20,};let routesComponentsTemplates={base:{mixins:[the_basest_view_mixin,collapsable_card_mixin],data:function(){return{data:{instance:{},parent_instances:{},},};},computed:{opt(){return{store_url:this.qs_url.replace(/^\/|\/$/g,""),};},content_body_component:function(){return"gui_entity_"+this.view.schema.type;},content_header_component:function(){return;},content_footer_component:function(){return;},content_additional:function(){return;},title:function(){return this.view.schema.name;},breadcrumbs:function(){let breadcrumb=[{name:"Home",link:"/",}];return breadcrumb.concat(this.getBreadcrumbParentPart(),this.getBreadcrumbCurrentPath(),);},url:function(){return this.$route.path;},qs_url:function(){return this.url;},error_data:function(){if(!this.error){return;}
return app.error_handler.errorToString(this.error);},},mounted(){this.$root.$on('eventHandler-'+this.$root.$children.last._uid,this.eventHandler);},created(){this.onCreatedHandler();},watch:{'$route':'fetchData'},methods:{openPage(options={}){this.$router.push(options);},openRedirectUrl(options={}){this.openPage(options);},onCreatedHandler(){this.fetchData();},eventHandler(method,opt){if(this[method]){this[method](opt);}},_getRedirectUrlFromResponse(response_data){let pk_key;let pk_value;let redirect_path;for(let key in response_data){if(key.indexOf("_id")!==-1){pk_key=key;pk_value=response_data[key];}}
if(!pk_key){return;}
let paths=Object.values(app.views).filter(item=>{if(item.schema.type=='page'&&item.schema.path.replace(/^\/|\/$/g,"").split("/").last=="{"+pk_key+"}"){return item;}}).map(item=>item.schema.path);redirect_path=findClosestPath(paths,this.$route.name);if(redirect_path){let obj={};obj[pk_key]=pk_value;return redirect_path.format($.extend(true,{},this.$route.params,obj)).replace(/\/$/g,"");}
redirect_path=Object.values(app.views).filter(item=>{if(item.schema.path.indexOf(pk_key.replace('_id',''))!==-1&&item.schema.type=='page'&&item.schema.level==3){return item;}}).map(item=>item.schema.path)[0];if(redirect_path){let f_obj={};f_obj[path_pk_key]=pk_value;return redirect_path.format(f_obj).replace(/\/$/g,"");}},executeEmptyActionOnInstance(opt={}){let url=this._executeEmptyActionOnInstance_getUrl(opt);if(!url){return;}
let method=opt.query_type||'post';let qs=this.getQuerySet(this.view,this.qs_url).clone({url:url});qs.formQueryAndSend(method).then(response=>{guiPopUp.success(pop_up_msg.instance.success.execute.format([opt.name,this.view.schema.name]));if(response&&response.data){try{let redirect_path=this._getRedirectUrlFromResponse(response.data);if(redirect_path){this.openRedirectUrl({path:redirect_path});}}catch(e){}}}).catch(error=>{let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.execute.format([opt.name,this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);debugger;});},_executeEmptyActionOnInstance_getUrl(opt={}){if(!opt.path){return;}
return opt.path.format(this.$route.params);},setQuerySet(view,url,qs){if(!qs){qs=view.objects.copy();qs.use_prefetch=true;}
qs.url=url.replace(/^\/|\/$/g,"");this.$store.commit('setQuerySet',{url:qs.url,queryset:qs,});return this.getQuerySet(view,url);},getQuerySet(view,url){let qs=this.$store.getters.getQuerySet(url.replace(/^\/|\/$/g,""));if(qs){return qs;}
return this.setQuerySet(view,url);},deleteQuerySet(url){this.$store.commit('deleteQuerySet',{url:url.replace(/^\/|\/$/g,""),});},deleteQuerySetFromSandBox(url){this.$store.commit('deleteQuerySetFromSandBox',{url:url.replace(/^\/|\/$/g,""),});},getInstance(view,url){return this.getQuerySet(view,url).get();},getParentPaths(path,url){let result=[];let views=this.$store.getters.getViews;let inner_path="/";let inner_url="/";let path_parts=path.replace(/^\/|\/$/g,"").split("/");let url_parts=url.replace(/^\/|\/$/g,"").split("/");for(let i=0;i<path_parts.length;i++){let test_path=inner_path+path_parts[i]+"/";let test_url=inner_url+url_parts[i]+"/";if(views[test_path]){if(test_path==this.$route.name){continue;}
inner_path=test_path;inner_url=test_url;result.push({path:inner_path,url:inner_url,});}}
return this.handleParentPaths(result);},getParentInstancesForPath(){let inner_paths=this.getParentPaths(this.$route.name,this.$route.path);let views=this.$store.getters.getViews;for(let index=0;index<inner_paths.length;index++){let obj=inner_paths[index];if(!this.loadParentInstanceOrNot(views,obj)){continue;}
this.getInstance(views[obj.path],obj.url).then(instance=>{this.data.parent_instances[obj.url]=instance;this.data.parent_instances={...this.data.parent_instances};}).catch(error=>{debugger;});}},handleParentPaths(parent_paths){return parent_paths;},loadParentInstanceOrNot(views,obj){if(views[obj.path]&&views[obj.path].schema.type=="list"){return false;}
return true;},fetchData(){this.setLoadingSuccessful();},getBreadcrumbNameForCurrentPath(){return false;},getBreadcrumbParentPart(){let breadcrumb=[];let parent_links=this.getParentPaths(this.$route.name,this.$route.path);for(let index=0;index<parent_links.length;index++){let parent_link=parent_links[index];let name=parent_link.url.replace(/^\/|\/$/g,"").split("/").last;let name_1;if(this.data.parent_instances[parent_link.url]){name_1=this.data.parent_instances[parent_link.url].getViewFieldValue();}
breadcrumb.push({name:name_1||name,link:parent_link.url.replace(/\/$/g,""),});}
return breadcrumb;},getBreadcrumbCurrentPath(){let breadcrumb=[];let name=this.url.replace(/\/$/g,"").split("/").last;let name_1=this.getBreadcrumbNameForCurrentPath();let current_bc={name:name_1||name,};if(isEmptyObject(this.$route.query)){breadcrumb.push(current_bc);return breadcrumb;}
current_bc.link=this.$route.path.replace(/\/$/g,"");breadcrumb.push(current_bc);let filters=[];let filters_keys=Object.keys(this.$route.query);let page=this.$route.query.page;if(page){filters_keys.splice(filters_keys.indexOf("page"),1);}
for(let index=0;index<filters_keys.length;index++){let key=filters_keys[index];filters.push([key,this.$route.query[key]].join('='));}
if(filters.length>0){let obj={name:"search: "+filters.join("&"),};if(page){obj.link=this.$route.path.replace(/\/$/g,"")+"?"+filters.join("&");}
breadcrumb.push(obj);}
if(page){breadcrumb.push({name:'page='+page,});}
return breadcrumb;}}},list:{mixins:[view_with_autoupdate_mixin],data:function(){return{data:{pagination:{count:0,page_size:list_props.page_size,page_number:1,},filters:{},instances:{},parent_instances:{},},};},computed:{multi_actions_button_component(){return"gui_entity_"+this.view.schema.type+"_footer";},},methods:{onCreatedHandler(){this.setSelection(this.qs_url);this.fetchData();},fetchData(){this.initLoading();this.setFilters(this.qs_url,this.generateBaseFilters());this.data.filters=this.getFilters(this.qs_url);let qs=this.setQuerySet(this.view,this.qs_url).filter(this.getFiltersPrepared(this.qs_url)).prefetch();this.setQuerySet(this.view,this.qs_url,qs);this.getInstancesList(this.view,this.qs_url).then(instances=>{this.setLoadingSuccessful();this.setInstancesToData(instances);if(this.view.schema.autoupdate){this.startAutoUpdate();}}).catch(error=>{this.setLoadingError(error);});this.getParentInstancesForPath();},setInstancesToData(instances){this.data.instances=instances;this.data.pagination.count=this.getQuerySet(this.view,this.qs_url).api_count;this.data.pagination.page_number=this.getFiltersPrepared(this.qs_url).page||1;},getInstancesList(view,url){return this.getQuerySet(view,url).items();},setSelection(url){url=url.replace(/^\/|\/$/g,"");if(!this.$store.getters.getSelections(url)){this.$store.commit('setSelection',url);}},generateBaseFilters(){let limit=this.data.pagination.page_size;let page=this.$route.query.page||1;let query={limit:limit,offset:limit*(page-1),};return $.extend(true,query,this.$route.query);},setFilters(url,filters){url=url.replace(/^\/|\/$/g,"");this.$store.commit('setFilters',{url:url,filters:filters,});},getFilters(url){return this.$store.getters.getFilters(url.replace(/^\/|\/$/g,""));},getFiltersPrepared(url){let filters=this.getFilters(url).cache.data;for(let key in filters){if(filters.hasOwnProperty(key)&&filters[key]===undefined){delete filters[key];}}
return filters;},filterInstances(){let hidden_filters=['offset','limit','page'];let filters=this.getFiltersPrepared(this.qs_url);for(let filter in filters){if(hidden_filters.includes(filter)){delete filters[filter];}}
this.openPage({name:this.$route.name,params:this.$route.params,query:filters,});},removeInstance(opt){let instance;for(let index=0;index<this.data.instances.length;index++){instance=this.data.instances[index];if(instance.getPkValue()==opt.instance_id){break;}}
if(!instance){return;}
instance.delete().then(response=>{this.removeInstances_callback(instance,response);}).catch(error=>{let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.remove.format([instance.getViewFieldValue(),this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);debugger;});},removeInstances(){let selections=this.$store.getters.getSelections(this.qs_url.replace(/^\/|\/$/g,""),);for(let id in selections){if(!selections[id]){continue;}
for(let index=0;index<this.data.instances.length;index++){let instance=this.data.instances[index];if(id==instance.getPkValue()){instance.delete().then(response=>{this.removeInstances_callback(instance,response);}).catch(error=>{let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.remove.format([instance.getViewFieldValue(),this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);debugger;});}}}},removeInstances_callback(instance,response){guiPopUp.success(pop_up_msg.instance.success.remove.format([instance.getViewFieldValue()||instance.getPkValue(),this.view.schema.name]));let url=this.qs_url.replace(/^\/|\/$/g,"")+"/"+
instance.getPkValue();this.deleteQuerySet(url);let ids={};ids[instance.getPkValue()]=false;this.$store.commit('setSelectionValuesByIds',{url:this.qs_url.replace(/^\/|\/$/g,""),ids:ids,});let new_qs=this.getQuerySet(this.view,this.qs_url).copy();if(!new_qs.cache){return;}
for(let index=0;index<new_qs.cache.length;index++){let list_instance=new_qs.cache[index];if(list_instance.getPkValue()==instance.getPkValue()){new_qs.cache.splice(index,1);this.setQuerySet(this.view,this.qs_url,new_qs);this.getInstancesList(this.view,this.qs_url).then(instances=>{this.setInstancesToData(instances);});}}},updateData(){let new_qs=this.getQuerySet(this.view,this.qs_url).clone().prefetch();return new_qs.items().then(instances=>{if(deepEqual(this.getQuerySet(this.view,this.qs_url).query,new_qs.query)){this.setQuerySet(this.view,this.qs_url,new_qs);this.setInstancesToData(instances);return true;}else{return false;}}).catch(error=>{debugger;});},_executeEmptyActionOnInstance_getUrl(opt={}){if(!opt.instance_id){return;}
return this.$route.path.replace(/\/$/g,"")+"/"+
opt.instance_id+"/"+opt.name+"/";},addChildInstance(opt){let qs=this.getQuerySet(this.view,this.qs_url).clone();qs.query={};qs.formQueryAndSend('post',opt.data).then(response=>{guiPopUp.success(pop_up_msg.instance.success.add.format([this.view.schema.name],));}).catch(error=>{let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.add.format([this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);debugger;});},},},page_new:{mixins:[editable_page_mixin],computed:{qs_url:function(){return this.url.replace("/new","");},title:function(){return"New "+this.view.schema.name;},},methods:{fetchData(){this.initLoading();let qs=this.setAndGetQuerySetFromSandBox(this.view,this.qs_url);this.data.instance=qs.cache=qs.model.getInstance({},qs);this.setLoadingSuccessful();this.getParentInstancesForPath();},setQuerySetInSandBox(view,url){let qs=this.setQuerySet(view,url);let sandbox_qs=qs.copy();this.$store.commit('setQuerySetInSandBox',{url:sandbox_qs.url,queryset:sandbox_qs,});},saveInstance(){let data=this.getValidData();if(!data){current_view.setLoadingError({});return;}
let qs=this.getQuerySetFromSandBox(this.view,this.qs_url).clone();let instance=qs.model.getInstance(data,qs);let method=this.view.schema.query_type;this.loading=true;instance.save(method).then(instance=>{this.loading=false;guiPopUp.success(pop_up_msg.instance.success.create.format([this.view.schema.name],));this.deleteQuerySetFromSandBox(this.qs_url);this.openRedirectUrl({path:this.getRedirectUrl({instance:instance})});}).catch(error=>{this.loading=false;let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.create.format([this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);current_view.setLoadingError(error);});},getRedirectUrl(opt){return[this.url.replace('/edit','').replace('/new',''),opt.instance.getPkValue()].join("/");},},},page:{mixins:[page_with_data_mixin,view_with_autoupdate_mixin],methods:{fetchData(){this.initLoading();this.getInstance(this.view,this.qs_url).then(instance=>{this.setLoadingSuccessful();this.data.instance=instance;if(this.view.schema.autoupdate){this.startAutoUpdate();}}).catch(error=>{debugger;this.setLoadingError(error);});this.getParentInstancesForPath();},getBreadcrumbNameForCurrentPath(){if(!isEmptyObject(this.data.instance)&&this.data.instance.data){return this.data.instance.getViewFieldValue();}},},},page_edit:{mixins:[page_with_data_mixin,editable_page_mixin],computed:{qs_url:function(){return this.url.replace("/edit","");},},methods:{fetchData(){this.initLoading();this.setAndGetInstanceFromSandBox(this.view,this.qs_url).then(instance=>{this.setLoadingSuccessful();this.data.instance=instance;}).catch(error=>{this.setLoadingError(error);debugger;});this.getParentInstancesForPath();},saveInstance(){let data=this.getValidData();if(!data){current_view.setLoadingError({});return;}
let instance=this.data.instance;instance.data=data;let method=this.view.schema.query_type;this.loading=true;instance.save(method).then(instance=>{this.loading=false;let qs=this.getQuerySet(this.view,this.qs_url).clone();qs.cache=instance;this.setQuerySet(this.view,this.qs_url,qs);guiPopUp.success(pop_up_msg.instance.success.save.format([instance.getViewFieldValue()||instance.getPkValue(),this.view.schema.name],));this.openRedirectUrl({path:this.getRedirectUrl({instance:instance})});}).catch(error=>{this.loading=false;let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.save.format([instance.getViewFieldValue(),this.view.schema.name,str],);app.error_handler.showError(srt_to_show,str);current_view.setLoadingError(error);});},reloadInstance(){let base_qs=this.getQuerySet(this.view,this.qs_url);if(!(base_qs&&base_qs.cache&&base_qs.cache.data)){return;}
this.$store.commit('setViewInstanceData',{url:this.qs_url.replace(/^\/|\/$/g,""),data:base_qs.cache.data,store:'sandbox',});setTimeout(()=>{this.$store.commit('setViewInstanceData',{url:this.qs_url.replace(/^\/|\/$/g,""),data:base_qs.cache.data,store:'sandbox',});},10);},getRedirectUrl(opt){return this.url.replace("/edit","");},},},action:{mixins:[editable_page_mixin],methods:{fetchData(){this.initLoading();let qs=this.setAndGetQuerySetFromSandBox(this.view,this.qs_url);this.data.instance=qs.cache=qs.model.getInstance({},qs);this.setLoadingSuccessful();this.getParentInstancesForPath();},setQuerySetInSandBox(view,url){let sandbox_qs=view.objects.clone({url:url.replace(/^\/|\/$/g,"")});this.$store.commit('setQuerySetInSandBox',{url:sandbox_qs.url,queryset:sandbox_qs,});},getRedirectUrl(opt){let r_data;if(opt.response&&opt.response.data){r_data=opt.response.data;}
if(!r_data){return this._getRedirectUrlBase(opt);}
try{let url=this._getRedirectUrlFromResponse(r_data);if(url){return url;}}catch(e){return this._getRedirectUrlBase(opt);}
return this._getRedirectUrlBase(opt);},_getRedirectUrlBase(opt){let parent_paths=this.getParentPaths(this.$route.name,this.url);let view=this.$store.getters.getView(parent_paths[parent_paths.length-1].path);let instance=view.objects.model.getInstance(opt.data,view.objects);let url_parts=this.url.replace("/edit","").replace("/new","").split("/").slice(0,-2);url_parts.push(instance.getPkValue());return url_parts.join("/");},executeInstance(){let data=this.getValidData();if(!data){current_view.setLoadingError({});return;}
let instance=this.data.instance;let method=this.view.schema.query_type;this.loading=true;instance.queryset.formQueryAndSend(method,data).then(response=>{this.loading=false;guiPopUp.success(pop_up_msg.instance.success.execute.format([this.view.schema.name,instance.name.toLowerCase()]));this.deleteQuerySetFromSandBox(this.qs_url);let data=response.data;this.openRedirectUrl({path:this.getRedirectUrl({data:data,response:response})});}).catch(error=>{this.loading=false;let str=app.error_handler.errorToString(error);let srt_to_show=pop_up_msg.instance.error.execute.format([this.view.schema.name,instance.name.toLowerCase(),str],);app.error_handler.showError(srt_to_show,str);current_view.setLoadingError({});});},}},};let customRoutesComponentsTemplates={home:{mixins:[the_basest_view_mixin],template:"#template_custom_view",data(){return{message:"Homepage content"};},computed:{title(){return'Home';}},},'404':{mixins:[the_basest_view_mixin],template:"#template_custom_view",data(){return{message:"Page with current URL was not found."};},computed:{title(){return'Error 404';}},},};