var base_button_mixin={props:['type','options','look'],template:"#template_button_common",computed:{title(){return this.options.title||this.options.name;},classes(){return this.getRepresentationProperty('classes');},class_with_name(){return'btn-'+this.type+'-'+this.options.name;},icon_classes(){return this.getRepresentationProperty('icon_classes');},title_classes(){return this.getRepresentationProperty('title_classes');},},methods:{getPkKeys(path){let pk_keys=path.match(/{[A-z0-9]+}/g);if(pk_keys){return pk_keys.map(pk_key=>pk_key.replace(/^{|}$/g,""));}
return[];},getPathParams(path){let pk_key=this.getPkKeys(path).last;if(pk_key&&this.instance_id){let params={};params[pk_key]=this.instance_id;return $.extend(true,{},this.$route.params,params);}
return this.$route.params;},onClickHandler(instance_id){if(this.options.empty){return this.doEmptyAction(this.options,instance_id);}
if(this.options.path){return this.goToPath(this.options.path);}
return this.doAction(instance_id);},goToPath(path_name){this.$router.push({name:path_name,params:this.getPathParams(path_name),})},doAction(instance_id){if(this.options.multi_action){this.$root.$emit('eventHandler-'+this.$root.$children.last._uid,this.options.name+'Instances');}else{this.$root.$emit('eventHandler-'+this.$root.$children.last._uid,this.options.name+'Instance',{instance_id:instance_id},);}},doEmptyAction(options,instance_id){let opt=options;if(typeof instance_id=='number'||typeof instance_id=='string'){opt=$.extend(true,{instance_id:instance_id},options);}
this.$root.$emit('eventHandler-'+this.$root.$children.last._uid,'executeEmptyActionOnInstance',opt,);},getRepresentationProperty(name){let property=[];if(this.look&&this.look[name]){property=this.look[name];}
if(this.options&&this.options[name]){property=this.options[name];}
return property;}},};var base_list_table_mixin={mixins:[hide_field_in_table_mixin],computed:{child_actions_exist:function(){return this.doesPropertyExist(this.schema,'child_links');},multi_actions_exist:function(){return this.doesPropertyExist(this.schema,'multi_actions');},},methods:{doesPropertyExist(obj,property){if(!obj[property]){return false;}
if(Array.isArray(obj[property])){return obj[property].length>0;}
if(typeof obj[property]=='object'){return Object.keys(obj[property]).length>0;}},td_classes(el,name){return addCssClassesToElement(el,name,this.schema.operation_id.replace('_list',''),);},},};var base_page_type_mixin={props:['data','view','opt'],template:"#template_entity_page",data(){return{options:{store:'objects',}}},computed:{instance(){return this.data.instance;},},};var page_new_and_action_type_mixin={data(){return{options:{hideReadOnly:true,store:'sandbox',}}},};var action_type_mixin={data(){let hideUnrequired=false;if(this.view.objects&&this.view.objects.model&&this.view.objects.model.fields&&Object.keys(this.view.objects.model.fields).length>6){hideUnrequired=true;}
return{options:{hideUnrequired:hideUnrequired,}}},};var base_instances_table_and_table_row_mixin={computed:{with_actions(){let p='enable_actions';return this.opt[p]!==undefined?this.opt[p]:this[p];},list_url(){return this.opt.url?this.opt.url:this.$route.path;},schema(){return this.opt.schema||{};},fields(){return this.opt.fields;},}};var base_instances_table_mixin={mixins:[base_list_table_mixin,base_instances_table_and_table_row_mixin],props:{instances:{type:Array,},opt:{default:()=>{},},},template:"#template_base_instances_list_table",data(){return{enable_multiple_select:false,enable_actions:false,};},computed:{with_multiple_select(){let p='enable_multiple_select';return this.opt[p]!==undefined?this.opt[p]:this[p];},table_classes(){return this.with_multiple_select?'multiple-select':'';},header_tr_classes(){return this.allSelected?'selected':'';},allSelected(){let selections=this.getSelections();for(let item in this.instances){let instance=this.instances[item];if(!selections[instance.getPkValue()]){return false;}}
return true;},},methods:{changeAllRowsSelection(){let ids={};for(let item in this.instances){let instance=this.instances[item];ids[instance.getPkValue()]=!this.allSelected;}
this.setSelections(ids);},getSelections(){return this.opt.selections;},setSelections(ids){this.$emit('setSelections',Object.assign(this.opt.selections,ids));},toggleSelection(opt){this.$emit('toggleSelection',opt);},row_opt(instance){return{view:this.opt.view,schema:this.schema,fields:this.fields,url:this.list_url,selected:this.opt.selections[instance.getPkValue()],}},},};var base_instances_table_row_mixin={mixins:[base_list_table_mixin,table_row_mixin,base_instances_table_and_table_row_mixin,],props:{instance:{type:Object,},opt:{default:()=>{return{};},},},template:"#template_base_instances_list_table_row",data(){return{blank_url:true,enable_select:true,enable_actions:false,};},computed:{with_select(){let p='enable_select';return this.opt[p]!==undefined?this.opt[p]:this[p];},selected:function(){return this.opt.selected;},tr_classes:function(){let classes=this.selected?'selected':'';for(let key in this.fields){let field=this.fields[key];if(field.options.format=='choices'||field.options.type=='choices'){classes+=" "+addCssClassesToElement('tr',this.instance.data[field.options.name],field.options.name,);}}
return classes;},base_url(){return this.list_url.replace(/\/$/g,"");},data_to_represent:function(){return this.instance.data;},_blank(){let p='blank_url';return this.opt[p]!==undefined?this.opt[p]:this[p];},child_links_buttons(){return this.opt.view.getViewSublinkButtons('child_links',this.schema.child_links,this.instance);},},methods:{toggleSelection(){this.$emit('toggleSelection',{id:this.instance.getPkValue()});},},};var sidebar_link_mixin={computed:{page_url(){if(this.$route&&this.$route.path){return this.$route.path;}else{return window.location.hash;}},},methods:{is_link_active(item,url){if(item.url==url){return true;}
if(url=="/"){return false;}
let instance=url.split("/")[1];if(!instance){return false;}
if(item.url&&item.url.indexOf(instance)==1){return true;}},},};var base_widget_mixin={props:{item:Object,value:{default:()=>{},},},};var w_line_chart_content_body_mixin={mixins:[base_widget_mixin],template:"#template_w_line_chart_content_body",data(){return{chart_instance:undefined,};},watch:{'value':function(value){this.generateChart();},'item.lines':{handler(value){this.generateChart();},deep:true,},},mounted(){this.generateChart();},methods:{generateChart(){try{this.chart_instance.destroy();}
catch(e){}
let el=$(this.$el).find('#chart_js_canvas');let chart_data=this.item.formChartData(this.value);this.chart_instance=this.item.generateChart(el,chart_data);},},};var w_line_chart_mixin={template:'#template_w_line_chart',mixins:[base_widget_mixin],data(){return{with_content_header:false,};},methods:{toggleCollapsed(){this.item.collapsed=!this.item.collapsed;},toggleActive(){this.item.active=!this.item.active;},},components:{content_body:{mixins:[w_line_chart_content_body_mixin],},},};var vst_vue_components={};vst_vue_components.items={preloader:Vue.component('preloader',{props:['show'],template:'#template_preloader',}),top_nav:Vue.component('top_nav',{template:"#template_top_nav",props:{a_links:{default:false,},},data(){return{gravatar:new Gravatar(),};},computed:{is_authenticated(){return window.is_authenticated;},enable_gravatar(){return window.enable_gravatar;},user(){return{id:my_user_id,email:my_user_email||"",first_name:my_user_first_name||"",last_name:my_user_last_name||"",}},gravatar_img(){return this.gravatar.getGravatarByEmail(this.user.email);},profile_url(){let url='/profile';if(this.a_links){return window.hostname+"/#"+url;}
return url;},profile_settings_url(){let url='/profile/settings';if(this.a_links){return window.hostname+"/#"+url;}
return url;},link_attr(){if(this.a_links){return'href';}
return'to';},link_component(){if(this.a_links){return'a';}
return'router-link';},openapi_url(){return window.openapi_url;},logout_url(){return window.gui_logout_url;},login_url(){return'/login/';}},methods:{getDefaultGravatarImg(){return this.gravatar.getDefaultGravatar();},setDefaultGravatar(el){el.src=this.getDefaultGravatarImg();return false;},},}),logo:Vue.component('logo',{props:['title'],template:"#template_logo",}),sidebar:Vue.component('sidebar',{props:{menu:Array,docs:Object,a_links:{default:false,},},template:"#template_sidebar",computed:{menu_items(){let url_prefix="";if(this.a_links){url_prefix=hostname;}
let items=[{name:'Home',url:url_prefix+'/',span_class:"fa fa-dashboard",origin_link:this.a_links,}];items=items.concat(this.menu||[]);if(this.docs&&this.docs.has_docs&&this.docs.docs_url){items.push({name:'Documentation',url:this.docs.docs_url,span_class:"fa fa-book",origin_link:true,});}
return items;},},methods:{hideSidebar(){if(window.innerWidth<=991){$('body').removeClass('sidebar-open');$('body').addClass('sidebar-collapse');}},},}),sidebar_link_wrapper:Vue.component('sidebar_link_wrapper',{mixins:[sidebar_link_mixin],props:['item'],template:"#template_sidebar_link2",data(){return{menu_open:false,};},watch:{'page_url':function(path){if(!this.are_sublinks_active&&this.menu_open){this.menu_open=false;}},'are_sublinks_active':function(val){this.menu_open=val;},'is_item_active':function(val){if(!this.are_sublinks_active){this.menu_open=val;}},},created(){this.menu_open=this.are_sublinks_active||this.is_item_active;},computed:{wrapper_classes(){let classes="";if(this.item.sublinks){classes+="menu-treeview has-treeview ";}
if(this.menu_open){classes+="menu-open ";}
return classes;},are_sublinks_active(){if(!this.item.sublinks){return false;}
for(let index in this.item.sublinks){let sublink=this.item.sublinks[index];if(this.is_link_active(sublink,this.page_url)){return true;}}
return false;},is_item_active(){return this.is_link_active(this.item,this.page_url);},},methods:{toggleMenuOpen(){this.menu_open=!this.menu_open;},hideSidebar(){this.$emit('hideSidebar');},}}),sidebar_link:Vue.component('sidebar_link',{mixins:[sidebar_link_mixin],props:['item'],template:"#template_sidebar_link",computed:{icon_classes(){return this.item.span_class;},link_classes(){if(this.is_link_active(this.item,this.page_url)){return'active';}
return"";},link_type(){if(this.item.origin_link||!this.item.url){return'a';}
return'router-link';},link_url(){return this.item.url||"";},link_url_attr(){if(this.link_type=='a'&&this.item.url){return'href';}
return'to';}},methods:{onLinkClickHandler(){if(this.item.url){return this.$emit('hideSidebar');}else{if(this.item.sublinks){return this.onToggleIconClickHandler();}}},onToggleIconClickHandler(){return this.$emit('toggleMenuOpen');}},}),main_footer:Vue.component('main_footer',{template:"#template_main_footer",computed:{project_version(){return app.api.openapi.info['x-versions'].application;},is_debug(){return window.isDebug;},},}),breadcrumbs:Vue.component('breadcrumbs',{props:['breadcrumbs'],template:"#template_breadcrumbs",}),gui_buttons_row:Vue.component('gui_buttons_row',{props:['view','data','opt'],template:"#template_buttons_row",computed:{schema(){return this.view.schema;},operations(){return this.getButtons('operations');},actions(){return this.getButtons('actions');},sublinks(){return this.getButtons('sublinks');},},methods:{getButtons(buttons_name){return this.view.getViewSublinkButtons(buttons_name,this.view.schema[buttons_name],this.data.instance);}},}),gui_group_of_buttons:Vue.component('gui_group_of_buttons',{props:['title','type','buttons','classes'],template:"#template_group_of_buttons",data:function(){return{window_width:window.innerWidth,}},mounted(){window.addEventListener('resize',()=>{this.window_width=window.innerWidth;})},computed:{groupButtonsOrNot(){let buttons_amount=0;if(typeof this.buttons=="number"){buttons_amount=this.buttons;}else if(typeof this.buttons=="string"){buttons_amount=Number(this.buttons)||0;}else if(typeof this.buttons=="object"){if($.isArray(this.buttons)){buttons_amount=this.buttons.length;}else{buttons_amount=Object.keys(this.buttons).length;}
for(let i in this.buttons){if(this.buttons[i].hidden){buttons_amount--;}}}
if(buttons_amount<2){return false;}else if(buttons_amount>=2&&buttons_amount<5){if(this.window_width>=992){return false;}}else if(buttons_amount>=5&&buttons_amount<8){if(this.window_width>=1200){return false;}}else if(buttons_amount>=8){if(this.window_width>=1620){return false;}}
return true;}}}),gui_buttons_list:Vue.component('gui_buttons_list',{props:['type','text','buttons','instance_id','look'],template:"#template_buttons_list",computed:{classes(){let classes=[];if(this.look&&this.look['classes']){classes=this.look['classes'];}
return classes;}}}),gui_multi_actions:Vue.component('gui_multi_actions',{props:['instances','multi_actions','opt'],template:"#template_multi_actions",computed:{store_url(){return this.opt.store_url;},current_path(){return this.$route.name;},text(){return"Actions on "+this.selected+" items";},classes(){return['btn-primary'];},selections(){return this.$store.getters.getSelections(this.store_url);},selected(){let count=0;for(let i in this.instances){let instance=this.instances[i];if(this.selections[instance.getPkValue()]){count++;}}
return count;},},}),gui_button_common:Vue.component('gui_button_common',{mixins:[base_button_mixin],computed:{classes(){let classes=this.getRepresentationProperty('classes');if(!classes){classes=[];}
if(Array.isArray(classes)){classes.push(this.class_with_name);}else if(typeof classes=='string'){classes=[classes,this.class_with_name];}
return classes;},},}),gui_button_li:Vue.component('gui_button_li',{mixins:[base_button_mixin],props:['options','instance_id'],template:"#template_button_li",}),gui_modal:Vue.component('gui_modal',{props:['opt'],template:"#template_modal",mounted(){window.addEventListener('keyup',this.escHandler);},beforeDestroy(){window.removeEventListener('keyup',this.escHandler);},computed:{with_header(){if(this.opt&&this.opt.header==false){return false;}
return true;},with_footer(){if(this.opt&&this.opt.footer==false){return false;}
return true;},},methods:{close(){this.$emit('close');},escHandler(e){if(e.code=='Escape'){this.close();}},}}),gui_help_modal:Vue.component('gui_help_modal',{mixins:[modal_window_and_button_mixin],template:"#template_help_modal",data(){return{info:app.api.openapi.info,}},methods:{isArray(item){return Array.isArray(item);},},}),gui_customizer:Vue.component('gui_customizer',{template:"#template_gui_customizer",data(){return{customizer:guiCustomizer,}},created(){this.customizer.init();},computed:{skin_settings(){return this.customizer.skin.settings;},skin_name(){return this.customizer.skin.name;},formField(){return this.customizer.formField;},skinField(){return this.customizer.skinField;},},methods:{formOnChangeHandler(value){return this.customizer.setSkinSettings(value);},skinOnChangeHandler(skin){return this.customizer.setSkin(skin);},},}),gui_entity_list:Vue.component('gui_entity_list',{props:['data','view','opt'],template:"#template_entity_list",computed:{fields(){return this.view.objects.model.fields;},is_empty(){return isEmptyObject(this.data.instances);}},}),gui_entity_list_header:Vue.component('gui_entity_list_header',{props:['data','view','opt'],template:"#template_entity_header_list",computed:{filters(){console.log('filters',this.view.schema.filters);return this.view.schema.filters;},filters_opt(){return $.extend(true,{},this.opt,{store:'filters'});},},}),gui_entity_list_footer:Vue.component('gui_entity_list_footer',{mixins:[base_list_table_mixin],props:['data','view','opt'],template:"#template_entity_footer_list",computed:{schema(){return this.view.schema;},}}),gui_list_table:Vue.component('gui_list_table',{mixins:[base_list_table_mixin],props:['instances','fields','view','opt'],template:"#template_list_table",computed:{store_url(){return this.opt.store_url;},allSelected(){let selections=this.$store.getters.getSelections(this.store_url);for(let item in this.instances){let instance=this.instances[item];if(!selections[instance.getPkValue()]){return false;}}
return true;},classes:function(){return this.allSelected?'selected':'';},schema(){return this.view.schema;},},methods:{changeAllRowsSelection(){let ids={};for(let item in this.instances){let instance=this.instances[item];ids[instance.getPkValue()]=!this.allSelected;}
this.$store.commit('setSelectionValuesByIds',{url:this.store_url,ids:ids,});},},}),pagination:Vue.component('pagination',{mixins:[main_pagination_mixin],}),gui_list_table_row:Vue.component('gui_list_table_row',{mixins:[base_list_table_mixin,table_row_mixin],props:['instance','fields','view','opt'],template:"#template_list_table_row",computed:{store_url(){return this.opt.store_url;},selected:function(){return this.$store.getters.getSelectionById({url:this.store_url,id:this.instance.getPkValue(),});},classes:function(){let classes=this.selected?'selected':'';for(let key in this.fields){let field=this.fields[key];if(field instanceof guiFields.choices){classes+=" "+addCssClassesToElement('tr',this.instance.data[field.options.name],field.options.name,);}}
return classes;},base_url:function(){return this.$route.path.replace(/\/$/g,"");},data_to_represent:function(){return this.instance.data;},schema(){return this.view.schema;},child_links_buttons(){return this.view.getViewSublinkButtons('child_links',this.schema.child_links,this.instance);},},methods:{toggleSelection(){this.$store.commit('toggleSelectionValue',{url:this.store_url,id:this.instance.getPkValue(),});},}}),gui_filters_modal:Vue.component('gui_filters_modal',{mixins:[modal_window_and_button_mixin],props:['opt','view','data'],template:"#template_filters_modal",methods:{filter(){this.$root.$emit('eventHandler-'+this.$root.$children.last._uid,'filterInstances',);},},}),gui_add_child_modal:Vue.component('gui_add_child_modal',{mixins:[base_modal_window_for_instance_list_mixin],props:['options'],template:"#template_add_child_modal",data(){return{child_view:undefined,selections:{},};},created(){this.child_view=app.views[this.options.list_paths[0]];this.qs=app.views[this.options.list_paths[0]].objects.clone();},computed:{fields(){return this.qs.model.fields;},schema(){return this.child_view.schema;},opt(){return{url:this.qs.url,view:this.child_view,schema:this.schema,fields:this.fields,enable_multiple_select:true,selections:this.selections,};},field_props(){return{view_field:this.qs.model.view_name,};},},methods:{open(){let filters=this.generateFilters();this.updateInstances(filters);},changeValue(opt){this.selections={...opt.selections};},addSelected(){for(let id in this.selections){let val=this.selections[id];if(!val){continue;}
this.addChildToParent(id);}
this.close();},addChildToParent(id){this.$root.$emit('eventHandler-'+this.$root.$children.last._uid,'addChildInstance',{data:{id:id}},);},onClose(){this.selections={...{}};},setSelections(opt){this.selections={...opt};},toggleSelection(opt){if(this.selections[opt.id]===undefined){this.selections[opt.id]=true;}else{this.selections[opt.id]=!this.selections[opt.id];}
this.selections={...this.selections};},onUpdateInstances(qs){this.qs=qs;}},components:{current_table:{mixins:[base_instances_table_mixin],watch:{selections(selections){this.$emit('changeValue',{selections:selections});}},components:{current_table_row:{mixins:[base_instances_table_row_mixin],},},},},}),gui_entity_page:Vue.component('gui_entity_page',{mixins:[base_page_type_mixin],data(){return{options:{readOnly:true,},}}}),fields_wrapper:Vue.component('fields_wrapper',{props:['instance','opt'],template:'#template_fields_wrapper',data(){return{hidden_store:{},};},created(){if(this.opt.hideUnrequired){for(let key in this.instance.fields){if(!this.instance.fields[key].options.required){this.hidden_store[key]=true;}else{this.hidden_store[key]=false;}}}},computed:{instance_data(){return this.instance.data},fields(){return this.instance.fields;},qs_url(){return this.instance.queryset.url;},show_fields_select(){if(this.opt.readOnly){return false;}
return this.opt.hideUnrequired;},},methods:{hideFieldOrNot(field){if(this.instance_data[field.options.name]!==undefined){return false;}
return this.hidden_store[field.options.name];},getFieldWrapperOpt(field){let w_opt=$.extend(true,{},this.opt,{qs_url:this.qs_url});if(this.opt.hideUnrequired){let hidden=this.hideFieldOrNot(field);return $.extend(true,{},w_opt,{hidden:hidden,hidden_button:true,});}
return w_opt;},addFieldHandler(field){this.hidden_store[field]=!this.hidden_store[field]||false;this.hidden_store={...this.hidden_store};},toggleHidden(opt){this.addFieldHandler(opt.field);},},}),filters_wrapper:Vue.component('filters_wrapper',{props:['view','opt','filters_data'],template:'#template_filters_wrapper',computed:{filters(){return this.view.schema.filters;},qs_url(){return this.opt.store_url;},data_to_represent(){return this.filters_data;},wrapper_opt(){return $.extend(true,{},this.opt,{qs_url:this.qs_url});},}}),gui_entity_page_new:Vue.component('gui_entity_page_new',{mixins:[base_page_type_mixin,page_new_and_action_type_mixin],}),gui_entity_page_edit:Vue.component('gui_entity_page_edit',{mixins:[base_page_type_mixin],data(){return{options:{store:'sandbox',},}}}),gui_entity_action:Vue.component('gui_entity_action',{mixins:[base_page_type_mixin,page_new_and_action_type_mixin,action_type_mixin],}),};vst_vue_components.widgets={w_counter:Vue.component('w_counter',{template:'#template_w_counter',props:{item:Object,value:{default:0,},},}),w_line_chart:Vue.component('w_line_chart',{mixins:[w_line_chart_mixin],}),};