(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["manage-database"],{"0bdf":function(e,n,t){},"133b":function(e,n,t){"use strict";t("b336")},1486:function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AddComponent"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NamedType",name:{kind:"Name",value:"AddComponentInput"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addComponent"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"costPerUnit"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"system"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"unit"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}]}}],loc:{start:0,end:197}};t.loc.source={body:"mutation AddComponent($input: AddComponentInput) {\n addComponent(input: $input) {\n id\n name\n costPerUnit\n system {\n id\n name\n }\n unit {\n id\n name\n }\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["AddComponent"]=s(t,"AddComponent")},"277b":function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateSystem"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NamedType",name:{kind:"Name",value:"CreateSystemInput"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createSystem"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"category"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"finCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"components"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"costPerUnit"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"unit"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}]}}]}}],loc:{start:0,end:263}};t.loc.source={body:"mutation CreateSystem($input: CreateSystemInput) {\n createSystem(input: $input) {\n id\n name\n category{\n id\n name\n }\n finCode\n components {\n id\n name\n costPerUnit\n unit {\n id\n name\n }\n }\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["CreateSystem"]=s(t,"CreateSystem")},"29bd":function(e,n,t){"use strict";t("d8e2")},"2f29":function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Categories"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"categories"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:56}};t.loc.source={body:"query Categories {\n categories {\n id\n name\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["Categories"]=s(t,"Categories")},"330b":function(e,n,t){"use strict";t("0bdf")},"369d":function(e,n,t){"use strict";t("780a")},"59f2":function(e,n,t){"use strict";t("6bec")},"6bec":function(e,n,t){},"780a":function(e,n,t){},"7ea8":function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteSystem"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteSystem"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[]}]}}],loc:{start:0,end:60}};t.loc.source={body:"mutation DeleteSystem($id: ID!) {\n deleteSystem(id: $id)\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["DeleteSystem"]=s(t,"DeleteSystem")},"86e2":function(e,n,t){"use strict";t("87be")},"87be":function(e,n,t){},"9d9a":function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteComponent"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteComponent"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[]}]}}],loc:{start:0,end:66}};t.loc.source={body:"mutation DeleteComponent($id: ID!) {\n deleteComponent(id: $id)\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["DeleteComponent"]=s(t,"DeleteComponent")},b336:function(e,n,t){},cd40:function(e,n){var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateComponent"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NamedType",name:{kind:"Name",value:"UpdateComponentInput"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateComponent"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"system"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"costPerUnit"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"unit"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}]}}],loc:{start:0,end:206}};t.loc.source={body:"mutation UpdateComponent($input: UpdateComponentInput) {\n updateComponent(input: $input) {\n id\n system {\n id\n name\n }\n name\n costPerUnit\n unit {\n id\n name\n }\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var t=e.type;"NamedType"===t.kind&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,n)})),e.definitions&&e.definitions.forEach((function(e){i(e,n)}))}var a={};function o(e,n){for(var t=0;t0){var d=r;r=new Set,d.forEach((function(e){if(!s.has(e)){s.add(e);var n=a[e]||new Set;n.forEach((function(e){r.add(e)}))}}))}return s.forEach((function(n){var i=o(e,n);i&&t.definitions.push(i)})),t}(function(){t.definitions.forEach((function(e){if(e.name){var n=new Set;i(e,n),a[e.name.value]=n}}))})(),e.exports=t,e.exports["UpdateComponent"]=s(t,"UpdateComponent")},d8e2:function(e,n,t){},dc09:function(e,n,t){"use strict";t.r(n);var i=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{staticClass:"manage-database"},[t("v-row",{staticClass:"mb-6"},[t("v-col",[t("h1",[e._v("Manage Database")])]),t("v-col",{directives:[{name:"show",rawName:"v-show",value:e.showAddSystemBtn,expression:"showAddSystemBtn"}],attrs:{cols:"auto"}},[t("modal",{attrs:{title:"Create System","max-width":"380"},scopedSlots:e._u([{key:"activator",fn:function(n){var i=n.on,a=n.attrs;return[t("btn",e._g(e._b({attrs:{width:"180"}},"btn",a,!1),i),[e._v("Create System")])]}},{key:"default",fn:function(e){var n=e.close;return[t("add-system",{on:{done:n}})]}}])})],1),t("v-col",{directives:[{name:"show",rawName:"v-show",value:e.showAddComponentBtn,expression:"showAddComponentBtn"}],attrs:{cols:"auto"}},[t("modal",{attrs:{title:"Create Component","max-width":"480"},scopedSlots:e._u([{key:"activator",fn:function(n){var i=n.on,a=n.attrs;return[t("btn",e._g(e._b({attrs:{width:"220"}},"btn",a,!1),i),[e._v("Create Component")])]}},{key:"default",fn:function(e){var n=e.close;return[t("add-component",{on:{done:n}})]}}])})],1)],1),t("v-row",[t("manage-database")],1)],1)},a=[],o=t("e78c"),s=t.n(o),r=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("ApolloQuery",{staticClass:"manage-database-container",attrs:{query:e.SYSTEMS_QUERY,"fetch-policy":"cache-and-network"},scopedSlots:e._u([{key:"default",fn:function(e){var n=e.result,i=n.loading,a=n.error,o=n.data;return[t("alert",{attrs:{error:a}}),t("database",{attrs:{systems:o&&o.systems||[],loading:i}})]}}])})},d=[],l=t("96f1"),u=t("b8ea"),c=t.n(u),m=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",[t("data-table",{attrs:{items:e.displayedItems,headers:e.displayedHeaders,height:"611px","hide-default-footer":!0,"disable-pagination":!0,"item-key":"index",loading:e.loading,"group-by":"name","empty-group-text":"There are no components"},scopedSlots:e._u([{key:"group.action",fn:function(n){var i=n.items;return[t("div",{staticClass:"table-actions-bar"},[e.showDeleteSystemBtn?t("confirmation-modal",{key:i[0].id,attrs:{mutation:e.DELETE_SYSTEM_MUTATION,variables:{id:i[0].id},title:"Delete System",message:"Are you sure you want to delete System?","ok-btn":{label:"Delete"},update:e.onSystemDelete(i[0])},scopedSlots:e._u([{key:"default",fn:function(n){var i=n.on,a=n.attrs;return[t("v-icon",e._g(e._b({staticClass:"action",attrs:{small:""}},"v-icon",{attrs:a},!1),i),[e._v(" far fa-trash-alt ")])]}}],null,!0)}):e._e()],1)]}},{key:"item.componentName",fn:function(n){return[t("v-edit-dialog",{ref:n.item.id+n.item.index,attrs:{small:""},on:{close:function(t){return e.saveComponent(n.item)},open:function(t){return e.onComponentOpen(n.item)}},scopedSlots:e._u([{key:"input",fn:function(){return[t("v-form",{staticStyle:{padding:"10px 0"},on:{submit:function(t){return t.preventDefault(),e.saveComponent(n.item)}},model:{value:e.valid,callback:function(n){e.valid=n},expression:"valid"}},[t("v-textarea",{attrs:{required:"",label:"Edit Component Name",autocomplete:"off","auto-grow":"",rows:"1"},on:{keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.preventDefault(),e.saveComponentName(n.item))}},model:{value:e.editComponentName,callback:function(n){e.editComponentName=n},expression:"editComponentName"}})],1)]},proxy:!0}],null,!0)},[t("span",{staticClass:"currency-cell"},[e._v(e._s(n.item.componentName))])])]}},{key:"item.costPerUnit",fn:function(n){return[t("v-edit-dialog",{attrs:{small:""},on:{close:function(t){return e.saveCost(n.item)},open:function(t){return e.onCostOpen(n.item)}},scopedSlots:e._u([{key:"input",fn:function(){return[t("v-form",{staticClass:"cost-edit-modal",on:{submit:function(t){return t.preventDefault(),e.saveCost(n.item)}},model:{value:e.valid,callback:function(n){e.valid=n},expression:"valid"}},[t("number-text-field",{attrs:{rules:[function(e){return null!==e&&""!==e||"Cost is Required"},e.positiveNumber,e.floatNumber(2)],required:"",label:"Edit Cost Per Unit",autocomplete:"off"},model:{value:e.editCost,callback:function(n){e.editCost=e._n(n)},expression:"editCost"}})],1)]},proxy:!0}],null,!0)},[t("span",{staticClass:"currency-cell"},[e._v(e._s(e._f("currency")(n.item.costPerUnit)))])])]}},{key:"item.actions",fn:function(n){var i=n.item;return[t("div",{staticClass:"table-actions-bar"},[e.showDeleteBtn?t("confirmation-modal",{attrs:{mutation:e.DELETE_COMPONENT_MUTATION,variables:{id:i.componentId},title:"Delete Component",message:"Are you sure you want to delete Component?","ok-btn":{label:"Delete"},update:e.onComponentDelete(i)},scopedSlots:e._u([{key:"default",fn:function(n){var i=n.on,a=n.attrs;return[t("v-icon",e._g(e._b({staticClass:"action",attrs:{small:""}},"v-icon",{attrs:a},!1),i),[e._v(" far fa-trash-alt ")])]}}],null,!0)}):e._e()],1)]}}])})],1)},f=[],v=t("2909"),p=t("5530"),y=(t("13d5"),t("d81d"),t("b0c0"),t("4de4"),t("c740"),t("a9b0")),k=t("7ea8"),b=t.n(k),h=t("9d9a"),S=t.n(h),g=t("d739"),N=t("cd40"),C=t.n(N),w=t("1182"),E=t("8ca5"),D=t.n(E),_=t("1a80"),x=t("24b2"),O=t("4169"),T=t("d42c"),F=t("b891"),U=t("a483"),A=t("9f02"),P={name:"Database",components:{Btn:l["a"],DataTable:y["a"],ConfirmationModal:g["a"],Modal:O["a"],EditUser:T["a"],NumberTextField:F["a"]},props:{systems:{type:Array,default:[]},loading:{type:Boolean}},apollo:{currentUser:{query:s.a,fetchPolicy:"cache-only"},units:{query:D.a,fetchPolicy:"cache-first"}},data:function(){return Object(p["a"])(Object(p["a"])({},U["a"]),{},{DELETE_SYSTEM_MUTATION:b.a,DELETE_COMPONENT_MUTATION:S.a,units:null,currentUser:null,editCost:"",editComponentName:"",valid:!0})},computed:{headers:function(){return[{text:"System",value:"name",type:"select",dataType:"string",width:"180px"},{text:"Category",value:"categoryName",type:"select",dataType:"string",width:"180px"},{text:"FIN Code",value:"finCode",type:"text",dataType:"string",width:"100px"},{text:"Component",value:"componentName",type:"select",dataType:"string",width:"180px"},{text:"Cost Per Unit",value:"costPerUnit",type:"number",dataType:"currency",width:"100px"},{text:"Unit",value:"unitName",type:"select",dataType:"string",width:"100px"},{text:"Actions",value:"actions",sortable:!1,width:"43px",fixed:!0,permissions:[x["c"].DELETE_DATABASE_COMPONENT,x["c"].DELETE_SYSTEM]}]},displayedItems:function(){return this.systems.length>0?this.systems.reduce((function(e,n){var t=null!==n.components&&n.components.length>0?n.components.map((function(e){return Object(p["a"])(Object(p["a"])({},n),{},{id:n.id,index:n.id+"_"+e.id,name:n.name,categoryName:n.category.name,componentName:e.name,componentId:e.id,costPerUnit:e.costPerUnit,unitName:e.unit.name,unitId:e.unit.id})})):[{id:n.id,index:n.id,name:n.name,finCode:null,categoryName:null,componentName:null,componentId:null,costPerUnit:null,unitName:null,unitId:null}];return e.push.apply(e,Object(v["a"])(t)),e}),[]):[]},displayedHeaders:function(){var e=this;return this.headers.filter((function(n){return!n.permissions||n.permissions.some((function(n){return Object(_["a"])(n,e.currentUser)}))}))},showEditBtn:function(){return Object(_["a"])(x["c"].EDIT_DATABASE_COMPONENT,this.currentUser)},showDeleteBtn:function(){return Object(_["a"])(x["c"].DELETE_DATABASE_COMPONENT,this.currentUser)},showDeleteSystemBtn:function(){return Object(_["a"])(x["c"].DELETE_SYSTEM,this.currentUser)}},methods:{onCostOpen:function(e){var n=this;setTimeout((function(){n.editCost=e.costPerUnit}),100)},onComponentOpen:function(e){var n=this;setTimeout((function(){n.editComponentName=e.componentName}),100)},saveCost:function(e){var n=this;if(this.valid)return this.$emit("cost-per-unit-change"),this.$apollo.mutate({mutation:C.a,variables:{input:{id:e.componentId,name:e.componentName,costPerUnit:this.editCost,unitId:e.unitId}}}).then((function(){e.costPerUnit=n.editCost,w["a"].$emit("show-snackbar",{color:"success",text:"Component ".concat(e.componentName," is updated!")})})).catch((function(e){w["a"].$emit("show-snackbar",{color:"error",text:Object(A["a"])(e.message)})})),!1},saveComponentName:function(e){this.$refs[e.id+e.index].cancel(),this.saveComponent(e)},saveComponent:function(e){var n=this;if(this.valid)return this.$apollo.mutate({mutation:C.a,variables:{input:{id:e.componentId,name:this.editComponentName,costPerUnit:e.costPerUnit,unitId:e.unitId}}}).then((function(){e.componentName=n.editComponentName,w["a"].$emit("show-snackbar",{color:"success",text:"Component ".concat(e.componentName," is updated!")})})).catch((function(e){w["a"].$emit("show-snackbar",{color:"error",text:Object(A["a"])(e.message)})})),!1},onSystemDelete:function(e){return function(n,t){var i=t.data.deleteSystem;if(i){var a=n.readQuery({query:c.a});a.systems=a.systems.filter((function(n){return n.id!==e.id})),n.writeQuery({query:c.a,data:a}),w["a"].$emit("show-snackbar",{color:"success",text:"System was deleted successfully!"})}}},onComponentDelete:function(e){return function(n,t){var i=t.data.deleteComponent;if(i){var a=n.readQuery({query:c.a}),o=a.systems.findIndex((function(n){return n.id===e.id}));o>=0&&(a.systems[o].components=a.systems[o].components.filter((function(n){return n.id!==e.componentId})),n.writeQuery({query:c.a,data:a})),w["a"].$emit("show-snackbar",{color:"success",text:"Component was deleted from the system successfully!"})}}}}},$=P,I=(t("330b"),t("2877")),q=t("6544"),M=t.n(q),V=t("7679"),j=t("4bd4"),R=t("132d"),B=t("a844"),L=Object(I["a"])($,m,f,!1,null,null,null),Q=L.exports;M()(L,{VEditDialog:V["a"],VForm:j["a"],VIcon:R["a"],VTextarea:B["a"]});var Y={name:"ManageDatabase",components:{Btn:l["a"],Database:Q},data:function(){return{SYSTEMS_QUERY:c.a}}},z=Y,G=(t("86e2"),Object(I["a"])(z,r,d,!1,null,null,null)),H=G.exports,J=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("ApolloMutation",e._g({staticClass:"add-system-form",attrs:{mutation:e.ADD_SYSTEM_MUTATION,variables:{input:{name:e.system.name,categoryId:e.system.category&&e.system.category.id||null,finCode:e.system.finCode}},update:e.updateSystems},scopedSlots:e._u([{key:"default",fn:function(n){var i=n.mutate,a=n.loading,o=n.error;return[a?e._e():t("alert",{attrs:{align:"center",error:o}}),t("system-form",e._b({on:{submit:function(e){return i()}}},"system-form",{btnLabel:"Create",loading:a,system:e.system},!1))]}}])},e.$listeners))},K=[],W=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("v-form",{ref:"form",staticClass:"system-form",attrs:{"lazy-validation":"","aria-busy":e.loading,disabled:e.loading,autocomplete:"off"},on:{submit:function(n){return n.preventDefault(),e.onSubmit(n)}}},[e.loading?e._e():t("alert",{attrs:{align:"center",error:e.error}}),t("v-text-field",{attrs:{rules:e.nameRules,label:"Name of System",required:"","validate-on-blur":"",autocomplete:"off"},model:{value:e.system.name,callback:function(n){e.$set(e.system,"name",n)},expression:"system.name"}}),t("v-select",{staticClass:"mt-1",attrs:{"item-text":"name",items:e.categories,rules:e.categoryRules,label:"Category",required:""},on:{input:function(n){return e.system.category=e.categories.find((function(e){return e.name===n}))}},model:{value:e.system.category,callback:function(n){e.$set(e.system,"category",n)},expression:"system.category"}}),t("number-text-field",{attrs:{label:"FIN Code",rules:[e.positiveNumber,e.integerNumber],"validate-on-blur":"",autocomplete:"off"},model:{value:e.system.finCode,callback:function(n){e.$set(e.system,"finCode",e._n(n))},expression:"system.finCode"}}),t("div",{staticClass:"mt-8 btns-bar"},[t("btn",{attrs:{type:"submit","full-width":"",disabled:e.loading}},[e._v(e._s(e.btnLabel))])],1)],1)},X=[],Z=t("2f29"),ee=t.n(Z),ne={name:"SystemForm",components:{Btn:l["a"],NumberTextField:F["a"]},props:{btnLabel:{type:String,required:!0},loading:{type:Boolean,default:!1},system:{type:Object}},apollo:{categories:{query:ee.a,fetchPolicy:"cache-first",error:function(e){this.error=e.networkError?Object(p["a"])(Object(p["a"])({},e),{},{message:"Something went wrong! Could not load categories."}):e}}},data:function(){return Object(p["a"])(Object(p["a"])({},U["a"]),{},{nameRules:[function(e){return!!e||"Name is Required"}],categoryRules:[function(e){return!!e||"Category is Required"}],categories:[],error:null})},methods:{validate:function(){return this.$refs.form.validate()},onSubmit:function(){this.validate()&&this.$emit("submit",this.user)}}},te=ne,ie=(t("369d"),t("b974")),ae=t("8654"),oe=Object(I["a"])(te,W,X,!1,null,null,null),se=oe.exports;M()(oe,{VForm:j["a"],VSelect:ie["a"],VTextField:ae["a"]});var re=t("277b"),de=t.n(re),le={name:"AddSystem",components:{SystemForm:se},data:function(){return{ADD_SYSTEM_MUTATION:de.a,system:{name:"",category:null,finCode:null}}},methods:{updateSystems:function(e,n){var t=n.data.createSystem;if(t){var i=e.readQuery({query:c.a});i.systems.unshift(t),e.writeQuery({query:c.a,data:i}),w["a"].$emit("show-snackbar",{color:"success",text:"System ".concat(this.system.name," was added successfully!")})}else w["a"].$emit("show-snackbar",{color:"error",text:"Error! Something went wrong... Please try later!"})}}},ue=le,ce=(t("59f2"),Object(I["a"])(ue,J,K,!1,null,null,null)),me=ce.exports,fe=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("ApolloMutation",e._g({staticClass:"add-component-form",attrs:{mutation:e.ADD_COMPONENT_MUTATION,variables:{input:{systemId:e.component.system,name:e.component.name,costPerUnit:e.component.costPerUnit,unitId:e.component.unit}},update:e.updateSystems},scopedSlots:e._u([{key:"default",fn:function(n){var i=n.mutate,a=n.loading,o=n.error;return[a?e._e():t("alert",{attrs:{align:"center",error:o}}),t("component-form",e._b({on:{submit:function(e){return i()}}},"component-form",{btnLabel:"Create",loading:a,component:e.component},!1))]}}])},e.$listeners))},ve=[],pe=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("v-form",{ref:"form",staticClass:"database-component-form",attrs:{"lazy-validation":"","aria-busy":e.loading,disabled:e.loading,autocomplete:"off"},on:{submit:function(n){return n.preventDefault(),e.onSubmit(n)}}},[e.loading?e._e():t("alert",{attrs:{align:"center",error:e.error}}),t("v-select",{attrs:{"item-text":"name","item-value":"id",items:e.systems,rules:e.systemRules,label:"System",required:"",autofocus:""},model:{value:e.component.system,callback:function(n){e.$set(e.component,"system",n)},expression:"component.system"}}),t("v-text-field",{attrs:{rules:e.nameRules,label:"Name of Component",required:"","validate-on-blur":"",autocomplete:"off"},model:{value:e.component.name,callback:function(n){e.$set(e.component,"name",n)},expression:"component.name"}}),t("v-text-field",{staticClass:"mt-1",attrs:{type:"number",rules:e.costRules,label:"Cost Per Unit",required:"",autocomplete:"off","validate-on-blur":""},model:{value:e.component.costPerUnit,callback:function(n){e.$set(e.component,"costPerUnit",e._n(n))},expression:"component.costPerUnit"}}),t("v-select",{staticClass:"mt-1",attrs:{"item-text":"name","item-value":"id",rules:e.unitRules,items:e.units,label:"Unit",required:""},model:{value:e.component.unit,callback:function(n){e.$set(e.component,"unit",n)},expression:"component.unit"}}),t("div",{staticClass:"mt-8 btns-bar"},[t("btn",{attrs:{type:"submit","full-width":"",disabled:e.loading}},[e._v(e._s(e.btnLabel))])],1)],1)},ye=[],ke=t("d907"),be={name:"ComponentForm",components:{Btn:l["a"]},apollo:{units:{query:D.a,fetchPolicy:"cache-first",error:function(e){this.error=e.networkError?Object(p["a"])(Object(p["a"])({},e),{},{message:"Something went wrong! Could not load unit list."}):e}},systems:{query:c.a,fetchPolicy:"cache-first",error:function(e){this.error=e.networkError?Object(p["a"])(Object(p["a"])({},e),{},{message:"Something went wrong! Could not load system list."}):e},update:function(e){return e.systems.sort(ke["a"])}}},props:{btnLabel:{type:String,required:!0},loading:{type:Boolean,default:!1},component:{type:Object}},data:function(){return{nameRules:[function(e){return!!e||"Name is Required"}],costRules:[function(e){return null!==e&&""!==e||"Cost is Required"},U["a"].positiveNumber,U["a"].floatNumber(2)],unitRules:[function(e){return!!e||"Unit is Required"}],units:[],systemRules:[function(e){return!!e||"System is Required"}],systems:[],error:null}},computed:{displayedRoles:function(){var e=Object(_["a"])(x["c"].ADD_ADMIN,this.currentUser);return e?this.roles:this.roles.filter((function(e){return"admin"!==e.name}))}},methods:{validate:function(){return this.$refs.form.validate()},onSubmit:function(){this.validate()&&this.$emit("submit",this.user)}}},he=be,Se=(t("29bd"),Object(I["a"])(he,pe,ye,!1,null,null,null)),ge=Se.exports;M()(Se,{VForm:j["a"],VSelect:ie["a"],VTextField:ae["a"]});var Ne=t("1486"),Ce=t.n(Ne),we={name:"AddComponent",components:{ComponentForm:ge},data:function(){return{ADD_COMPONENT_MUTATION:Ce.a,component:{system:null,name:"",costPerUnit:1,unit:null}}},methods:{updateSystems:function(e,n){var t=n.data.addComponent;if(t){var i=e.readQuery({query:c.a}),a=i.systems.findIndex((function(e){return e.id===t.system.id}));-1!==a&&(null===i.systems[a].components&&(i.systems[a].components=[]),i.systems[a].components.unshift(t),e.writeQuery({query:c.a,data:i})),w["a"].$emit("show-snackbar",{color:"success",text:"Component ".concat(this.component.name," was added successfully!")})}else w["a"].$emit("show-snackbar",{color:"error",text:"Error! Something went wrong... Please try later!"})}}},Ee=we,De=(t("133b"),Object(I["a"])(Ee,fe,ve,!1,null,null,null)),_e=De.exports,xe={components:{AddSystem:me,AddComponent:_e,Modal:O["a"],ManageDatabase:H,Btn:l["a"]},apollo:{currentUser:{query:s.a,fetchPolicy:"cache-only"}},data:function(){return{currentUser:null}},computed:{showAddSystemBtn:function(){return Object(_["a"])(x["c"].CREATE_SYSTEM,this.currentUser)},showAddComponentBtn:function(){return Object(_["a"])(x["c"].CREATE_DATABASE_COMPONENT,this.currentUser)}}},Oe=xe,Te=t("62ad"),Fe=t("0fd9"),Ue=Object(I["a"])(Oe,i,a,!1,null,null,null);n["default"]=Ue.exports;M()(Ue,{VCol:Te["a"],VRow:Fe["a"]})}}]); //# sourceMappingURL=manage-database.908701ac.js.map