@questwork/vue-q-widget-vue3 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +16 -0
- package/LICENSE +9 -0
- package/dist/q-widget.min.js +14 -0
- package/dist/q-widget.min.js.LICENSE.txt +1 -0
- package/lib/helpers/controller/index.js +11 -0
- package/lib/helpers/controller/saveState.js +26 -0
- package/lib/helpers/controller/showError.js +27 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utilities/configHandler/configHandler.js +26 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/buttonsHandler.js +41 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/elementQFormConfigHandler.js +38 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/index.js +1 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQForm/layoutHandler.js +54 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/actionsHandler.js +41 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/bulkActionHandler.js +53 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/elementQListConfigHandler.js +43 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/headersHandler.js +48 -0
- package/lib/helpers/utilities/configHandler/handlers/elementQList/index.js +1 -0
- package/lib/helpers/utilities/configHandler/handlers/index.js +15 -0
- package/lib/helpers/utilities/configHandler/index.js +1 -0
- package/lib/helpers/utilities/index.js +2 -0
- package/lib/helpers/utilities/setId/index.js +1 -0
- package/lib/helpers/utilities/setId/setId.js +10 -0
- package/lib/index.js +2 -0
- package/lib/models/configs/config.js +23 -0
- package/lib/models/configs/elementQForm/buttonHandler.js +68 -0
- package/lib/models/configs/elementQForm/elementQForm.js +34 -0
- package/lib/models/configs/elementQForm/index.js +1 -0
- package/lib/models/configs/elementQForm/makeFormHandler.js +27 -0
- package/lib/models/configs/elementQForm/nodeHandler.js +60 -0
- package/lib/models/configs/elementQGrid/elementQGrid.js +50 -0
- package/lib/models/configs/elementQGrid/index.js +1 -0
- package/lib/models/configs/elementQGrid/makeClasses.js +86 -0
- package/lib/models/configs/elementQList/elementQList.js +75 -0
- package/lib/models/configs/elementQList/index.js +1 -0
- package/lib/models/configs/elementQList/makeQWidgetQListBulkButton.js +78 -0
- package/lib/models/configs/elementQList/makeQWidgetQListButton.js +83 -0
- package/lib/models/configs/elementQList/makeQWidgetQListHeader.js +75 -0
- package/lib/models/configs/index.js +3 -0
- package/lib/models/controller/controller.js +67 -0
- package/lib/models/controller/index.js +1 -0
- package/lib/models/controllerHelpers/controllerHelpers.js +46 -0
- package/lib/models/controllerHelpers/index.js +1 -0
- package/lib/models/factories/index.js +1 -0
- package/lib/models/factories/nodeFactory.js +55 -0
- package/lib/models/index.js +5 -0
- package/lib/models/nodes/container.js +37 -0
- package/lib/models/nodes/containers/box.js +16 -0
- package/lib/models/nodes/containers/column.js +16 -0
- package/lib/models/nodes/containers/headerSticky.js +16 -0
- package/lib/models/nodes/containers/index.js +18 -0
- package/lib/models/nodes/containers/row.js +16 -0
- package/lib/models/nodes/element.js +124 -0
- package/lib/models/nodes/elements/index.js +33 -0
- package/lib/models/nodes/elements/qButton.js +15 -0
- package/lib/models/nodes/elements/qForm.js +67 -0
- package/lib/models/nodes/elements/qGrid.js +35 -0
- package/lib/models/nodes/elements/qHtml.js +15 -0
- package/lib/models/nodes/elements/qImport.js +15 -0
- package/lib/models/nodes/elements/qLabel.js +15 -0
- package/lib/models/nodes/elements/qList.js +46 -0
- package/lib/models/nodes/elements/qPaginator.js +20 -0
- package/lib/models/nodes/elements/qTab.js +19 -0
- package/lib/models/nodes/index.js +21 -0
- package/lib/models/nodes/node.js +69 -0
- package/package.json +73 -0
- package/vite.config.js +52 -0
package/.babelrc.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright 2019 Questwork Consulting Limited
|
|
2
|
+
|
|
3
|
+
This project is free software released under the MIT/X11 license:
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*! For license information please see q-widget.min.js.LICENSE.txt */
|
|
2
|
+
!(function(y,r){
|
|
3
|
+
const returns = r(module, require("vue"));
|
|
4
|
+
if (typeof exports == "object" && typeof module < "u") {
|
|
5
|
+
module.exports = returns;
|
|
6
|
+
exports.QWidget = returns.QWidget;
|
|
7
|
+
}
|
|
8
|
+
else if (typeof define == "function" && define.amd) {
|
|
9
|
+
define(["exports", "vue", r]);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
y.QWidget = returns.QWidget;
|
|
13
|
+
}
|
|
14
|
+
})(this,function(y,r){"use strict";const m=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n},P={name:"q-widget-q-modal",props:{modal:{type:Object,default:()=>({})}},data(){return{}},computed:{body(){return this.modal.body},css(){return this.modal.css},countdown(){return this.modal.countdown},label(){return this.modal.label},model(){return this.modal.model},onCancel(){return this.modal.onCancel},onClose(){return this.modal.onClose},onConfirm(){return this.modal.onConfirm},title(){return this.modal.title}},methods:{onFinish(){this.modal.onFinish()},qForm(t){this.modal.qForm(t)}}},U={class:"q-widget-q-modal __modal"};function K(t,e,n,o,i,s){const l=r.resolveComponent("q-modal",!0);return r.openBlock(),r.createElementBlock("div",U,[r.createVNode(l,{body:s.body,countdown:s.countdown,css:s.css,label:s.label,model:s.model,onCancel:s.onCancel,onClose:s.onClose,onConfirm:s.onConfirm,title:s.title,onOnFinish:s.onFinish,onQForm:s.qForm},null,8,["body","countdown","css","label","model","onCancel","onClose","onConfirm","title","onOnFinish","onQForm"])])}const j=m(P,[["render",K],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/QModal.vue"]]);function I({controller:t,state:e,saveControllerState:n}){const{saveStateKeys:o=[]}=t,i=o.reduce((s,l)=>({...s,...S({keys:l.split("."),obj:e})}),{});return n({data:i})}function S({keys:t,obj:e}){const n=t.shift();return{[n]:t.length===0?e[n]:S({keys:t,obj:e[n]})}}function C({component:t,message:e,modalConfig:n={}}){const{countdown:o,label:i,title:s,canClose:l=!0}=n,a={body:[{customComponentName:"q-modal-region-tool-html",html:e}],countdown:o,label:i,onClose:l?()=>{t.modal=null}:null,title:s||"Error"};t.modal=a}class z{static exec({config:e,keys:n,permissions:o}){Array.isArray(e)||console.log("can not handle these buttons");const i=n.shift();return n.length!==0&&console.log(`can not handle ${n.join(".")}`),T({buttons:e,key:i,permissions:o})}}function T({buttons:t,key:e,permissions:n}){return t.map(o=>{if(W(e,o)){const i=o.permissions||[];return{...o,permissions:[...i,...n]}}return o})}function W(t,e){const{buttonType:n,id:o,label:i}=e;return t===o||t===i||t===n}class M{static exec({config:e,keys:n,permissions:o}){return b({layout:e,keys:n,permissions:o})}}function b({layout:t,keys:e,permissions:n}){const o=e[0],{children:i,permissions:s}=t;if(G(o,t)){if(e.shift(),e.length===0)return{...t,permissions:[...s||[],...n]};if(Array.isArray(i))return{...t,children:i.map(l=>b({layout:l,keys:[...e],permissions:n}))};console.log(`can not handle ${e.join(".")}`)}return Array.isArray(i)?{...t,children:i.map(l=>b({layout:l,keys:[...e],permissions:n}))}:t}function G(t,e){const{id:n,name:o}=e;return t===n||t===o}class J{static exec({config:e,keys:n,permissions:o}){const i=n.shift();let s=null;switch(i){case"buttons":{s=z;break}case"layout":{s=M;break}default:{s=null;break}}return!s||typeof s.exec!="function"?e:{...e,[i]:s.exec({config:e[i],keys:[...n],permissions:o})}}}class Y{static exec({config:e,keys:n,permissions:o}){Array.isArray(e)||console.log("can not handle these actions");const i=n.shift();return n.length!==0&&console.log(`can not handle ${n.join(".")}`),X({actions:e,key:i,permissions:o})}}function X({actions:t,key:e,permissions:n}){return t.map(o=>{if(Z(e,o)){const i=o.permissions||[];return{...o,permissions:[...i,...n]}}return o})}function Z(t,e){const{id:n,label:o}=e;return t===n||t===o}class ee{static exec({config:e,keys:n,permissions:o}){const i=n.shift();switch(i){case"actions":return{...e,actions:te({actions:e[i],keys:n,permissions:o})};default:return e}}}function te({actions:t,keys:e,permissions:n}){Array.isArray(t)||console.log("can not handle these actions");const o=e.shift();return e.length!==0?(console.log(`can not handle ${e.join(".")}`),t):t.map(i=>{if(ne(o,i)){const s=i.permissions||[];return{...i,permissions:[...s,...n]}}return i})}function ne(t,e){const{id:n,label:o}=e;return t===n||t===o}class se{static exec({config:e,keys:n,permissions:o}){return Array.isArray(e)||console.log("can not handle these actions"),N({headers:e,keys:n,permissions:o})}}function N({headers:t,keys:e,permissions:n}){const o=e.shift();return t.map(i=>{if(re(o,i)){const{permissions:s,children:l}=i;return e.length!==0?Array.isArray(l)&&l.length>0?{...i,children:N({headers:l,keys:e,permissions:n})}:(console.log(`can not handle ${e.join(".")}`),i):{...i,permissions:[...s||[],...n]}}return i})}function re(t,e){const{id:n,label:o,key:i}=e;return t===n||t===o||t===i}class ie{static exec({config:e,keys:n,permissions:o}){const i=n.shift();let s=null;switch(i){case"actions":{s=Y;break}case"bulkAction":{s=ee;break}case"headers":{s=se;break}default:{s=null;break}}return!s||typeof s.exec!="function"?e:{...e,[i]:s.exec({config:e[i],keys:[...n],permissions:o})}}}const oe={ElementQForm:J,ElementQList:ie};function le({config:t,configPermissions:e=[],type:n}){return e.reduce((i,s)=>{const l=ae(n);if(!l||typeof l.exec!="function")return console.log("no config handler"),i;const{key:a,value:u}=s;return l.exec({config:i,keys:a.split("."),permissions:u})},t)}function ae(t){return oe[t]||null}function H(t){return`${t}-${Math.floor(Math.random()*1e9)}`}class q{constructor(e={}){this.css=e.css,this.configType="Config"}get isValid(){return!!this}static init(e){const n=new this(e);return n.isValid?n:null}}function ce(t,e){const{button:n,klass:o}=t,{element:i}=e,s=i.getState()||{},{formData:l={}}=s;class a extends o{constructor(c){super(c),this.hidden=c.hidden||!1,this.permissionResult=c.permissionResult,this.permissionResultHandler(this.permissionResult)}get isValid(){return!this.hidden&&super.isValid}static init(c,d){if(c instanceof a)return c;const g=c.permissions?d.permissionHandler(c.permissions,l):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},_=new a({...c,permissionResult:g});return _.isValid?_:null}permissionResultHandler(c){const{event:d,isAllowCreate:g,isAllowRead:_,isAllowUpdate:E,isAllowDelete:B}=c;d?typeof this[d]=="function"?this[d]({val:!0}):console.log(`do not have the event ${d}`):g&&_&&E&&B||this.setHidden({val:!0})}setDisabled({val:c}){this.disabled=c}setHidden({val:c}){this.hidden=c}}return a.init(n,e)}function de(t,e){const{layout:n,klass:o}=t,{element:i}=e,s=i.getState()||{},{formData:l={}}=s;class a extends o{constructor(d){super(d),this.permissionResult=d.permissions?e.permissionHandler(d.permissions,l):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},this.permissionResultHandler(this.permissionResult)}permissionResultHandler(d){const{event:g,isAllowCreate:_,isAllowRead:E,isAllowUpdate:B,isAllowDelete:kn}=d;g?typeof this[g]=="function"?this[g]({val:!0}):console.log(`do not have the event ${g}`):E?B||this.setPreview({val:!0}):this.setHidden({val:!0}),Array.isArray(this.children)&&this.children.forEach(hn=>{hn.permissionResultHandler(d)})}setDecoratorDisabled({val:d}){this.setDisabled({val:d})}setDecoratorHidden({val:d}){this.setHidden({val:d})}setDecoratorPreview({val:d}){this.setPreview({val:d})}}return a.init(n)}function ue(t){return e=>{const{type:n}=e;switch(n){case"button":return ce(e,t);case"node":return de(e,t);default:return null}}}class A extends q{constructor(e={}){super(e),this.configType="ElementQFormConfig",this.buttons=e.buttons,this.css=e.css||{},this.disabledForm=e.disabledForm||!1,this.eventName=e.eventName||{},this.formHandler=ue(e.helpers),this.layout=e.layout,this.previewForm=e.previewForm||!1,this.updateLayoutConfigs=e.updateLayoutConfigs||[]}get isValid(){return!!this}static init(e){const n=new this(e);return n.isValid?n:null}}function me({helpers:t}){const{element:e}=t,{getClasses:n}=e.getHandlers(),{Cell:o}=t.qGrid;class i extends o{constructor(l){super(l),typeof l.hidden=="function"?this.permissionHidden=l.hidden(this.item.item,this):this.permissionHidden=l.hidden||!1,this.permissionResult=l.permissionResult,this.permissionResultHandler(this.permissionResult,l.customComponentName)}get isValid(){return this.permissionHidden===!1}static init(l){const{permissions:a}=l,u=a?t.permissionHandler(a):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},c=new this({...l,permissionResult:u});return c.isValid?c:null}permissionResultHandler(l,a){const{event:u,isAllowCreate:c,isAllowRead:d,isAllowUpdate:g,isAllowDelete:_}=l;if(u){typeof this[u]=="function"?this[u]({val:!0}):console.log(`do not have the event ${u}`);return}(!(a==="q-grid-body-row-cell-button")&&!d||!(c&&d&&g&&_))&&this.setHidden({val:!0})}setHidden({val:l}){this.permissionHidden=l}}return typeof n!="function"?{Cell:i}:n({helpers:{Cell:i,...t}})}class L extends q{constructor(e={}){super(e),this.configType="ElementQGridConfig",this.classes=me({helpers:e.helpers}),this.converter=he({helpers:e.helpers}),this.eventName=e.eventName,this.layout=e.layout,this.fillLastRow=e.fillLastRow,this.placeholder=e.placeholder,this.urlDelegate=e.urlDelegate}get isValid(){return!!this}static init(e){const n=new this(e);return n.isValid?n:null}}function he({helpers:t}){const{element:e}=t,{converter:n}=e.getHandlers();if(typeof n!="function")return i=>i;const{QItem:o}=t.qGrid;return n({helpers:{QItem:o,...t}})}function fe({helpers:t}){const{QListBulkButton:e}=t.qList,{getValidation:n}=t.qUtilities;class o extends e{constructor(s){super(s),this.hidden=s.hidden||!1,this.permissionResult=s.permissionResult,this.permissionResultHandler(this.permissionResult)}get isValid(){return!this.hidden}static init(s,l){if(s instanceof o)return s;const{restriction:a,permissions:u}=s,c=l.controller.getState();if(!n({rule:a,data:c}))return null;const d=u?l.permissionHandler(u):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},g=new o({...s,permissionResult:d});return g.isValid?g:null}static initFromArray(s,l){return Array.isArray(s)?s.map(a=>this.init(a,l)):[]}static initOnlyValidFromArray(s,l){return this.initFromArray(s,l).filter(a=>a)}permissionResultHandler(s){const{event:l,isAllowCreate:a,isAllowRead:u,isAllowUpdate:c,isAllowDelete:d}=s;l?typeof this[l]=="function"?this[l]({val:!0}):console.log(`do not have the event ${l}`):a&&u&&c&&d||this.setHidden({val:!0})}setHidden({val:s}){this.hidden=s}}return o}function ge({helpers:t}){const{QListButton:e}=t.qList;class n extends e{constructor(i){super(i),this.endpoint=O(i.endpoint,i.qRow),this.httpMethod=i.httpMethod,this.hidden=i.hidden||!1,this.permissionResult=i.permissionResult,this.permissionResultHandler(this.permissionResult),this.url=O(i.url,i.qRow)}get isValid(){return!this.hidden&&super.isValid}static init(i,s){if(i instanceof n)return i;const l=i.permissions?s.permissionHandler(i.permissions,i.qRow.get()):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},a=new n({...i,permissionResult:l});return a.isValid?a:null}static initFromArray(i,s){return Array.isArray(i)?i.map(l=>this.init(l,s)):[]}static initOnlyValidFromArray(i,s){return this.initFromArray(i,s).filter(l=>l)}permissionResultHandler(i){const{event:s,isAllowCreate:l,isAllowRead:a,isAllowUpdate:u,isAllowDelete:c}=i;s?typeof this[s]=="function"?this[s]({val:!0}):console.log(`do not have the event ${s}`):l&&a&&u&&c||this.setHidden({val:!0})}setHidden({val:i}){this.hidden=i}}return n}function O(t,e){if(!t)return"";const n=/\$\{(.+?)\}/g;return t.replace(n,(o,i)=>e.get(i.trim()))}function pe(){class t{constructor(n){Object.keys(n).forEach(o=>{this[o]=n[o]}),this.hidden=n.hidden||!1,this.permissionResult=n.permissionResult,this.permissionResultHandler(this.permissionResult)}get isValid(){return!this.hidden}static init(n,o){if(n instanceof t)return n;const{children:i,permissions:s}=n,l=s?o.permissionHandler(s):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},a=new t({...n,children:Array.isArray(i)?this.initOnlyValidFromArray(i,o):null,permissionResult:l});return a.isValid?a:null}static initFromArray(n,o){return Array.isArray(n)?n.map(i=>this.init(i,o)):[]}static initOnlyValidFromArray(n,o){return this.initFromArray(n,o).filter(i=>i)}permissionResultHandler(n){const{event:o,isAllowCreate:i,isAllowRead:s,isAllowUpdate:l,isAllowDelete:a}=n;o?typeof this[o]=="function"?this[o]({val:!0}):console.log(`do not have the event ${o}`):s||this.setHidden({val:!0})}setHidden({val:n}){this.hidden=n}}return t}class x extends q{constructor(e={}){super(e),this.configType="ElementQListConfig",this.bulkAction=ye({bulkAction:e.bulkAction,helpers:e.helpers}),this.converter=Ce({actions:e.actions,helpers:e.helpers}),this.css=e.css,this.eventName=e.eventName,this.headers=_e({headers:e.headers,helpers:e.helpers}),this.listStyle=e.listStyle||"q-list-table",this.listShowFooter=e.showFooter||!1,this.listSortBys=e.sortBys,this.noDataMessage=e.noDataMessage}get isValid(){return!!this}static init(e){const n=new this(e);return n.isValid?n:null}}function ye({bulkAction:t={},helpers:e}){const n=fe({helpers:e});return{...t,actions:n.initOnlyValidFromArray(t.actions,e)}}function _e({headers:t,helpers:e}){return pe().initOnlyValidFromArray(t,e)}function Ce({actions:t,helpers:e}){const{QRow:n}=e.qList,i={QListButton:ge({helpers:e}),QRow:n,...e},{element:s}=i,{converter:l}=s.getHandlers();return typeof l!="function"?a=>a:l({actions:t,helpers:i})}class R{constructor(e){this.permissionHandler=ke,Object.keys(e).forEach(n=>{this[n]=e[n]})}static init(e){const n=new R(e);return n.isValid?n:null}get isValid(){return f(this.getControllerState)&&f(this.getControllerUniqueKey)&&f(this.saveControllerState)&&f(this.startLoading)&&f(this.stopLoading)&&f(this.runChains)&&this.qForm&&f(this.qForm.NodeHelper)&&this.qGrid&&f(this.qGrid.QItem)&&f(this.qGrid.Cell)&&this.qList&&f(this.qList.QRow)&&f(this.qList.QListBulkButton)&&f(this.qList.QListButton)&&this.qUtilities&&f(this.qUtilities.convertString)&&f(this.qUtilities.getValidation)&&f(this.qUtilities.lodash)}}function f(t){return typeof t=="function"}function ke(){return{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0}}class ${constructor(e={}){this.id=e.id||H("node"),this.css=e.css||{},this.hidden=e.hidden||!1,this.nodeType="Node",this.permissionResult=e.permissionResult,this.permissionResultHandler(this.permissionResult)}get isValid(){return!!this.id&&!this.hidden}get isCreated(){return!!this}static init(e){const n=new this(e);return n.isValid?n:null}getElementState(){return this}getType(){return this.type}isExist(e){const{name:n}=this;return!!e.find(o=>n&&o.name===n)}permissionResultHandler(e){const{event:n,isAllowCreate:o,isAllowRead:i,isAllowUpdate:s,isAllowDelete:l}=e;n?typeof this[n]=="function"?this[n]({val:!0}):console.log(`do not have the event ${n}`):o&&i&&s&&l||this.setHidden({val:!0})}setHidden({val:e}){this.hidden=e}updateElementState(e){return this}}let k=class extends ${constructor(e={}){super(e),this.children=e.children||[],this.nodeType="Container"}getChildren(){return this.children}getValidChildren(){return this.getChildren().filter(e=>e)}getElementState(){return this.getValidChildren().reduce((e,n)=>({...e,...n.getElementState()}),{})}updateElementState(e){return this.getValidChildren().forEach(n=>n.updateElementState(e)),this}};class ve extends k{constructor(e={}){super(e),this.nodeType="ContainerBox"}}class we extends k{constructor(e={}){super(e),this.nodeType="ContainerColumn"}}class Ee extends k{constructor(e={}){super(e),this.nodeType="ContainerHeaderSticky"}}class be extends k{constructor(e={}){super(e),this.nodeType="ContainerRow"}}const qe={ContainerBox:ve,ContainerColumn:we,ContainerHeaderSticky:Ee,ContainerRow:be};let p=class extends ${constructor(e={}){super(e),this.configPermissions=e.configPermissions,this.name=e.name,this.nodeType=e.nodeType||"Element",this.state={},this.configHandler(e.config)}get isCreated(){return super.isCreated&&!!this.component}get isValid(){return super.isValid&&!!this.name}get hasConfigPermissions(){return!!this.configPermissions}get stateName(){return{...this.defaultStateName,...this.config.stateName}}addComponent(e){this.component=e}configHandler(e={}){this.hasConfigPermissions?this.config=le({config:e,configPermissions:this.configPermissions,type:this.nodeType}):this.config=e}getConfig(){return this.config||{}}getComponent(){return this.component}getElementName(){return this.name}getHandlers(){const e=this.getElementName(),{elementHandlers:n={}}=this.state;return n[e]||{}}getState(){return this.state}getElementState(){return Re(this.state,this.stateName)}onCreated({component:e,payload:n={}}){return this.addComponent(e),this.updateState(n),this}update(e){this.updateElementState(e)}updateState(e){this.state={...this.state,...e}}updateElementState(e){const n=$e(e,this.stateName);return this.updateState(n),this}};function Re(t,e){return Object.keys(e).reduce((n,o)=>{const i=e[o],s=t[o];return{...n,[i]:s}},{})}function $e(t,e){return Object.keys(e).reduce((n,o)=>{const i=e[o],s=t[i];return delete n[i],{...n,[o]:s}},t)}class Be extends p{constructor(e={}){super(e)}}class Se extends p{constructor(e={}){super(e),this.defaultStateName={axios:"axios",formData:"formData",formErrors:"formErrors",formNode:"formNode",pageKey:"pageKey",qForm:"qForm"}}getConfig(e){let n=this.config||{};if(this.state.qForm){const{lodash:o}=e.qUtilities,i=Ne(this.state.qForm);n=o.mergeWith(i,n||{},Q)}return typeof A=="function"?A.init({...n,helpers:{...e,element:this}}):{}}getFormCustomizer(){const{formCustomizer:e}=this.getHandlers();return typeof e=="function"?e:Q}}function Q(t,e){if(Array.isArray(t))return e||null;if(typeof e=="number"||typeof e=="boolean")return e;if(!e)return null}function Ne(t){const{buttons:e=[],layout:n={},trees:o=[]}=t||{};return{buttons:e,layout:n,trees:o}}class He extends p{constructor(e={}){super(e),this.defaultStateName={gridItems:"gridItems"}}getConfig(e){let n=this.config||{};return this.state.qGrid&&(n={...this.state.qGrid,...n}),typeof L=="function"?L.init({...n,helpers:{...e,element:this}}):{}}}class Ae extends p{constructor(e={}){super(e)}}class Le extends p{constructor(e={}){super(e)}}class Oe extends p{constructor(e={}){super(e)}}class xe extends p{constructor(e={}){super(e),this.defaultStateName={qList:"qList",qSorterKeys:"qSorterKeys",rows:"rows"}}getConfig(e){let n=this.config||{};return this.state.qList&&(n={...Qe(this.state.qList),...n}),typeof x=="function"?x.init({...n,helpers:{...e,element:this}}):{}}}function Qe(t){return{...t}}class De extends p{constructor(e={}){super(e),this.defaultStateName={currentPage:"currentPage",currentPageSize:"currentPageSize",totalRecords:"totalRecords"}}}class Ve extends p{constructor(e={}){super(e),this.defaultStateName={active:"active",tabLayout:"tabLayout"}}}const h={...qe,...{ElementQButton:Be,ElementQForm:Se,ElementQGrid:He,ElementQHtml:Ae,ElementQImport:Le,ElementQLabel:Oe,ElementQList:xe,ElementQPaginator:De,ElementQTab:Ve},Container:k,Element:p,Node:$};class Fe{static init({layout:e={},controllerHelpers:n={}}={}){return D({layout:e,nodes:[],controllerHelpers:n})}}function D({layout:t,nodes:e,controllerHelpers:n}){if(t instanceof h.Node)return t;const o={...t};return Array.isArray(o.children)&&(o.children=o.children.map(i=>D({layout:i,nodes:e,controllerHelpers:n}))),Pe(o,e,n)}function Pe(t,e,n){const{nodeType:o,permissions:i}=t||{};if(typeof h[o]=="function"){const{permissionHandler:s}=n,l=i?s(i):{isAllowCreate:!0,isAllowRead:!0,isAllowUpdate:!0,isAllowDelete:!0},a=h[o].init({...t,permissionResult:l});return a?a.isExist(e)?null:(e.push(a),a):null}return null}class Ue{constructor(e={}){this.css=e.css||{},this.controllerHelpers=e.controllerHelpers,this.eventHandlers=e.eventHandlers||{},this.id=e.id||H("controller"),this.initialState=e.initialState,this.name=e.name,this.saveStateKeys=e.saveStateKeys||[],this.setLayout(e.layout,e.controllerHelpers)}get isValid(){return!!this.id&&!!this.layout}static init(e){const n=new this(e);return n.isValid?n:null}getElements(){return this.elements||[]}getElementByElementName(e){return this.elements.find(n=>n.getElementName()===e)}getState(){return{...this.getControllerState(),...this.layout.getElementState()}}getControllerState(){return this.state}setLayout(e,n){this.layout=Fe.init({layout:e,controllerHelpers:n})}setElements(e){this.elements=e}updateState(e){this.state={...this.state,...e},this.layout.updateElementState(this.state)}}const v={beforeCreate(){this.$options.components={...this.$options.components,QWidgetContainersContainer:r.defineAsyncComponent(()=>Promise.resolve().then(()=>pt)),QWidgetElementsElement:r.defineAsyncComponent(()=>Promise.resolve().then(()=>mn))}},methods:{currentContainer(t){return t instanceof h.Container?"q-widget-containers-container":t instanceof h.Element?"q-widget-elements-element":""}}},Ke={name:"q-widget-controller",components:{QModal:j},mixins:[v],provide(){return{helpers:{...this.controllerHelpers,controller:this.controller}}},props:{controller:{type:Object,default:()=>({})}},data(){return{isReady:!1,loadingCount:0,modal:null,renderKey:0}},computed:{controllerHelpers(){return this.controller.controllerHelpers},eventHandlers(){return this.controller.eventHandlers||{}},initControllerState(){return this.controller.initialState},node(){return this.controller.layout}},created(){this.init()},methods:{async init(){try{const{getControllerState:t}=this.controllerHelpers;let e=this.initControllerState;typeof t=="function"&&(e=await t({state:e}));const{onCreated:n}=this.eventHandlers;n&&(e=await this.runEventChains({state:e,event:n})),this.updateState(e)}catch(t){C({component:this,message:t.message})}finally{this.isReady=!0,this.reRenderElements()}},async callbackEmit({event:t,payload:e}){console.log("callbackEmit",t,e)},async callbackSubscribe(t,{event:e,payload:n,cb:o}){if(t===this.controllerHelpers.getControllerUniqueKey())try{const{key:i}=e,{controllerSubscribed:s}=this.eventHandlers,l=s[i];let a=this.controller.getState();l&&(a=await this.runEventChains({state:{...a,eventPayload:n},event:l})),typeof o=="function"&&await o({event:e,payload:a})}catch(i){C({component:this,message:i.message})}},getKey(t,e){return`${this.renderKey}-${t}-${e} `},getLoadingFunctions({scope:t=""}){const{startLoading:e,stopLoading:n}=this.controllerHelpers;switch(t){case"full":return{startLoading:e,stopLoading:n};case"none":return null;case"self":return{startLoading:this.startSelfLoading,stopLoading:this.stopSelfLoading};default:return{startLoading:e,stopLoading:n}}},async onEvent(t){try{const{eventName:e,element:n,payload:o}=t,{elementEvents:i={}}=this.eventHandlers,s=i[e];s?await this.runEventChains({state:{...this.controller.getState(),eventPayload:o,eventElement:n},event:s}):console.log(`can not find the event ${e}`)}catch(e){C({component:this,message:e.message,modalConfig:{title:"提示"}})}},async onElementCreated(t){try{this.controller.setElements(t);const e=this.eventHandlers.onElementCreated;e&&await this.runEventChains({state:this.controller.getState(),event:e})}catch(e){C({component:this,message:e.message})}},reRenderElements(){this.renderKey+=1},async runEventChains({event:t,state:e}){let n=e;const o=Ie({event:t}),i=this.getLoadingFunctions({scope:o});try{if(V({loadingFunctions:i,action:"start"}),t){const s={body:{...e},controller:this.controller,component:this,controllerHelpers:{...this.controllerHelpers,callbackEmit:this.callbackEmit,callbackSubscribe:this.callbackSubscribe,runEventChains:this.runEventChains,reRenderElements:this.reRenderElements,showError:C,updateState:this.updateState}},{runChains:l}=this.controllerHelpers,u=(await l({event:t,payload:s})).getResult();n={...n,...je(u)}}return console.log(n),n}catch(s){throw new Error(s.message)}finally{V({loadingFunctions:i,action:"stop"})}},startSelfLoading(){this.loadingCount+=1},stopSelfLoading(){this.loadingCount-=1},updateState(t){this.controller.updateState(t);const{saveControllerState:e}=this.controllerHelpers;typeof e=="function"&&I({controller:this.controller,state:t,saveControllerState:e})}}};function je(t={}){const{obj:e={}}=t,{body:n={}}=e;return n}function Ie({event:t={}}={}){return t.scope||"full"}function V({loadingFunctions:t,action:e}){if(t){const{startLoading:n,stopLoading:o}=t;switch(e){case"start":{n();break}case"stop":{o();break}}}}const ze={class:"q-widget-controller __controller"};function Te(t,e,n,o,i,s){const l=r.resolveComponent("q-modal");return r.openBlock(),r.createElementBlock("div",ze,[(r.openBlock(),r.createBlock(r.resolveDynamicComponent(t.currentContainer(s.node)),{key:i.renderKey,controllerReady:i.isReady,node:s.node,loadingCount:i.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["controllerReady","node","loadingCount","onOnEvent","onOnElementCreated"])),i.modal?(r.openBlock(),r.createBlock(l,{key:s.getKey("modal",i.modal),modal:i.modal},null,8,["modal"])):r.createCommentVNode("v-if",!0)])}const We={name:"q-widget",components:{QWidgetController:m(Ke,[["render",Te],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Controller.vue"]])},props:{content:{type:Object,default:()=>({})},contentHelpers:{type:Object,default:()=>({})},controller:{type:Object,default:()=>null},controllerHelpers:{type:Object,default:()=>null}},data(){return{controllerHelpersInstence:null,controllerInstence:null,error:null}},computed:{hasError(){return this.error}},created(){this.init()},methods:{init(){try{const t=this.controllerHelpers||this.contentHelpers;if(this.controllerHelpersInstence=R.init(t),!this.controllerHelpersInstence)throw new Error("invalid controller helpers");const e=this.controller||this.content;if(this.controllerInstence=Ue.init({...e,controllerHelpers:this.controllerHelpersInstence}),!this.controllerInstence)throw new Error("invalid controller")}catch(t){this.error=t.message||"invalid controller"}}}},Me={class:"q-widget"},Ge={key:1,class:"__error"};function Je(t,e,n,o,i,s){const l=r.resolveComponent("q-widget-controller");return r.openBlock(),r.createElementBlock("div",Me,[s.hasError?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createBlock(l,{key:0,controller:i.controllerInstence},null,8,["controller"])),s.hasError?(r.openBlock(),r.createElementBlock("div",Ge,r.toDisplayString(i.error),1)):r.createCommentVNode("v-if",!0)])}const w=m(We,[["render",Je],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/QWidget.vue"]]);function Ye(t){t.component(w.name,w)}w.install=Ye;const Xe={name:"q-widget-containers-box",mixins:[v],props:{controllerReady:{type:Boolean,default:!1},getKey:{type:Function,default:()=>null},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],computed:{children(){return this.node.children||[]}},methods:{onEvent(t){this.$emit("onEvent",t)},onElementCreated(t){this.$emit("onElementCreated",t)}}},Ze={class:"q-widget-containers-box __outer-box"},et={class:"__inner-box"};function tt(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",Ze,[r.createElementVNode("div",et,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(s.children,(l,a)=>(r.openBlock(),r.createBlock(r.resolveDynamicComponent(t.currentContainer(l)),{key:n.getKey("box",a),controllerReady:n.controllerReady,node:l,loadingCount:n.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["controllerReady","node","loadingCount","onOnEvent","onOnElementCreated"]))),128))])])}const nt=m(Xe,[["render",tt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Containers/Box.vue"]]),st={name:"q-widget-containers-column",mixins:[v],props:{controllerReady:{type:Boolean,default:!1},getKey:{type:Function,default:()=>null},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],computed:{children(){return this.node.children||[]}},methods:{onEvent(t){this.$emit("onEvent",t)},onElementCreated(t){this.$emit("onElementCreated",t)}}},rt={class:"q-widget-containers-column __column"};function it(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",rt,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(s.children,(l,a)=>(r.openBlock(),r.createBlock(r.resolveDynamicComponent(t.currentContainer(l)),{key:n.getKey("cloumn",a),controllerReady:n.controllerReady,node:l,loadingCount:n.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["controllerReady","node","loadingCount","onOnEvent","onOnElementCreated"]))),128))])}const ot=m(st,[["render",it],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Containers/Column.vue"]]),lt={name:"q-widget-containers-header-sticky",mixins:[v],props:{controllerReady:{type:Boolean,default:!1},getKey:{type:Function,default:()=>null},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],computed:{children(){return this.node.children||[]}},methods:{onEvent(t){this.$emit("onEvent",t)},onElementCreated(t){this.$emit("onElementCreated",t)}}},at={class:"q-widget-containers-header-sticky __header __sticky --sticky-top"};function ct(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",at,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(s.children,(l,a)=>(r.openBlock(),r.createBlock(r.resolveDynamicComponent(t.currentContainer(l)),{key:n.getKey("header-sticky",a),controllerReady:n.controllerReady,node:l,loadingCount:n.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["controllerReady","node","loadingCount","onOnEvent","onOnElementCreated"]))),128))])}const dt=m(lt,[["render",ct],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Containers/HeaderSticky.vue"]]),ut={name:"q-widget-containers-row",mixins:[v],props:{controllerReady:{type:Boolean,default:!1},getKey:{type:Function,default:()=>null},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],computed:{children(){return this.node.children||[]}},methods:{onEvent(t){this.$emit("onEvent",t)},onElementCreated(t){this.$emit("onElementCreated",t)}}},mt={class:"q-widget-containers-row __row"};function ht(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",mt,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(s.children,(l,a)=>(r.openBlock(),r.createBlock(r.resolveDynamicComponent(t.currentContainer(l)),{key:n.getKey("row",a),controllerReady:n.controllerReady,node:l,loadingCount:n.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["controllerReady","node","loadingCount","onOnEvent","onOnElementCreated"]))),128))])}const ft={name:"q-widget-containers-container",components:{QWidgetBoxContainer:nt,QWidgetColumnContainer:ot,QWidgetHeaderStickyContainer:dt,QWidgetRowContainer:m(ut,[["render",ht],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Containers/Row.vue"]])},props:{controllerReady:{type:Boolean,default:!1},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],data(){return{createdChildren:[]}},computed:{children(){return this.node.getValidChildren()||[]}},methods:{factoryInit(t){return t instanceof h.ContainerBox?"q-widget-box-container":t instanceof h.ContainerColumn?"q-widget-column-container":t instanceof h.ContainerHeaderSticky?"q-widget-header-sticky-container":t instanceof h.ContainerRow?"q-widget-row-container":""},getClass(t){return t.css||""},getKey(t,e){return`${t}-${e}`},onEvent(t){this.$emit("onEvent",t)},onElementCreated(t){if(this.createdChildren.push(t),this.createdChildren.length===this.children.length){const e=this.createdChildren.reduce((n,o)=>[...n,...o],[]);this.$emit("onElementCreated",e)}}}};function gt(t,e,n,o,i,s){return r.openBlock(),r.createBlock(r.resolveDynamicComponent(s.factoryInit(n.node)),{class:r.normalizeClass(s.getClass(n.node)),controllerReady:n.controllerReady,getKey:s.getKey,node:n.node,loadingCount:n.loadingCount,onOnEvent:s.onEvent,onOnElementCreated:s.onElementCreated},null,40,["class","controllerReady","getKey","node","loadingCount","onOnEvent","onOnElementCreated"])}const pt=Object.freeze(Object.defineProperty({__proto__:null,default:m(ft,[["render",gt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Containers/Container.vue"]])},Symbol.toStringTag,{value:"Module"})),yt={name:"q-widget-elements-adapters-q-button",inject:["helpers"],props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],computed:{$button(){return this.$config.button||{}},$config(){return this.element.getConfig()},$event(){return this.$button.event||"onButtonClick"},$url(){return this.$button.url||""},button(){return{...this.$button,url:this.url}},url(){const t=this.$config.patternMatch||/\$\{(.+?)\}/g,{convertString:e}=this.helpers.qUtilities;return e(this.$url,t,this.state)},isReady(){return this.loadingCount<=0&&this.controllerReady}},created(){this.controllerReady&&this.init()},methods:{init(){this.element.onCreated({component:this}),this.$emit("onCreated")},getClass(t){return t.css||""},onClick(t){const e={eventName:this.$event,payload:t};this.$emit("onEvent",e)}}},_t={key:1};function Ct(t,e,n,o,i,s){const l=r.resolveComponent("q-button",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-button q-widget-adapters-q-button __element __adapter __button __flex",s.getClass(n.element)])},[s.isReady?(r.openBlock(),r.createBlock(l,{key:0,class:"q-button",button:s.button,onClick:s.onClick,onOnChange:s.onClick,onUpload:s.onClick},null,8,["button","onClick","onOnChange","onUpload"])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",_t,e[0]||(e[0]=[r.createElementVNode("div",{class:"button __loading-box"},[r.createElementVNode("div",{class:"skeleton"},[r.createElementVNode("div",{class:"skeleton__tr"},[r.createElementVNode("div",{class:"skeleton__td"})])])],-1)])))],2)}const kt=m(yt,[["render",Ct],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QButton.vue"]]),vt={name:"q-widget-elements-adapters-q-form",inject:["helpers"],props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],data(){return{formErrors:[],formValue:null,initPageKey:"",isFormReady:!1}},computed:{$buttons(){return this.$config.buttons||[]},$config(){return this.element.getConfig(this.helpers)},$disabledForm(){return this.$config.disabledForm||!1},$eventName(){return this.$config.eventName||{}},$formCss(){return this.$config.css||{}},$formHandler(){return this.$config.formHandler},$layout(){return this.$config.layout},$previewForm(){return this.$config.previewForm||!1},axios(){return this.state.axios},elementHandlers(){return this.element.getHandlers()},customizer(){return this.element.getFormCustomizer()},displayLayout(){return this.getLayout()},formData(){return this.state.formData},isReady(){return this.loadingCount<=0&&this.controllerReady},pageKey(){return this.state.pageKey||this.initPageKey||""}},created(){this.controllerReady&&this.init()},methods:{init(){const{lodash:t}=this.helpers.qUtilities;this.formValue=t.cloneDeep(this.formData),this.isFormReady=!0},getClass(t){return t.css||""},getLayout(){const{NodeHelper:t}=this.helpers.qForm,{convertString:e,getValidation:n}=this.helpers.qUtilities;return Et({config:this.$config,convertString:e,getValidation:n,layout:this.$layout,NodeHelper:t,state:this.state})},onChange(t){const{node:e}=t;this.formErrors=[];const n=e.save({errors:this.formErrors}),{lodash:o}=this.helpers.qUtilities,i=o.mergeWith(this.formValue,n,this.customizer),l={eventName:this.$eventName.onFormChange||"onFormChange",payload:{...t,formData:i,errors:this.formErrors}};this.$emit("onEvent",l)},onClick(t){const{value:e,event:n}=t,{lodash:o}=this.helpers.qUtilities,i=o.mergeWith(this.formValue,e,this.customizer),s={eventName:n,payload:{...t,errors:this.formErrors,formData:i}};this.$emit("onEvent",s)},onCreated(t){const{pageKey:e,node:n}=t;this.initPageKey=e;const{afterSave:o}=this.elementHandlers;typeof o=="function"&&n.subscribe("afterSave",o({node:n,state:this.state})),this.formErrors=[],n.save({errors:this.formErrors}),this.element.onCreated({component:this,payload:{...t,formErrors:this.formErrors,formNode:n,pageKey:e}}),this.$emit("onCreated")}}};function wt(t,e,n,o){const i=/['"]\$\{(.+?)\}['"]/g;return JSON.parse(o(JSON.stringify(t),i,n))}function Et({config:t={},convertString:e,getValidation:n,layout:o,NodeHelper:i,state:s}){const l=bt({config:t,getValidation:n,layout:o,NodeHelper:i,state:s});return wt(l,t,s,e)}function bt({config:t={},getValidation:e,layout:n,NodeHelper:o,state:i}){let s=n;const{updateLayoutConfigs:l=[]}=t;return typeof o.updateNode=="function"&&l.forEach(a=>{const{key:u,value:c,type:d,restriction:g}=a;e({rule:g,data:i})&&(s=o.updateNode({keys:u.split("."),value:c,layout:s,type:d}))}),s}const qt={key:0,class:"__form __flex"},Rt={key:1};function $t(t,e,n,o,i,s){const l=r.resolveComponent("q-form",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-form q-widget-adapters-q-form __element __adapter",s.getClass(n.element)])},[s.isReady?(r.openBlock(),r.createElementBlock("div",qt,[i.isFormReady?(r.openBlock(),r.createBlock(l,{key:0,axios:s.axios,buttons:s.$buttons,css:s.$formCss,disabledForm:s.$disabledForm,formHandler:s.$formHandler,layout:s.displayLayout,pageKey:s.pageKey,previewForm:s.$previewForm,value:i.formValue,onOnClick:s.onClick,onOnChange:s.onChange,onOnCreated:s.onCreated},null,8,["axios","buttons","css","disabledForm","formHandler","layout","pageKey","previewForm","value","onOnClick","onOnChange","onOnCreated"])):r.createCommentVNode("v-if",!0)])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",Rt,e[0]||(e[0]=[r.createStaticVNode('<div class="__loading-box"><div class="skeleton"><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div></div></div></div>',1)])))],2)}const Bt=m(vt,[["render",$t],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QForm.vue"]]),St={name:"q-widget-elements-adapters-q-grid",inject:["helpers"],props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],data(){return{itemsData:[]}},computed:{$cellHandler(){return this.$config.cellHandler},$classes(){return this.$config.classes},$config(){return this.element.getConfig(this.helpers)},$converter(){return this.$config.converter},$eventName(){return this.$config.eventName||{}},$fillLastRow(){return this.$config.fillLastRow||!1},$gridCss(){return this.$config.css||""},$placeholder(){return this.$config.placeholder||null},$urlDelegate(){return this.$config.urlDelegate||""},gridItems(){return this.state.gridItems},isReady(){return this.loadingCount<=0&&this.controllerReady},layout(){return this.$config.layout}},created(){this.controllerReady&&this.init()},methods:{init(){this.itemsData=this.gridItems.map(this.$converter),this.element.onCreated({component:this}),this.$emit("onCreated")},getClass(t){return t.css||""},onClickGridItem(t){const n={eventName:this.$eventName.onClickGridItem||"onClickGridItem",payload:t};this.$emit("onEvent",n)},onButtonClick(t){const n={eventName:this.$eventName.onClick||"onClick",payload:t};this.$emit("onEvent",n)}}},Nt={key:1};function Ht(t,e,n,o,i,s){const l=r.resolveComponent("q-grid",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-grid q-widget-adapters-q-grid __element __adapter __grid",s.getClass(n.element)])},[s.isReady?(r.openBlock(),r.createBlock(l,{key:0,cellHandler:s.$cellHandler,classes:s.$classes,css:s.$gridCss,fillLastRow:s.$fillLastRow,items:i.itemsData,layout:s.layout,placeholder:s.$placeholder,urlDelegate:s.$urlDelegate,onOnClick:s.onButtonClick,onOnClickGridItem:s.onClickGridItem},null,8,["cellHandler","classes","css","fillLastRow","items","layout","placeholder","urlDelegate","onOnClick","onOnClickGridItem"])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",Nt," Loading "))],2)}const At=m(St,[["render",Ht],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QGrid.vue"]]),Lt={name:"q-widget-elements-adapters-q-html",inject:["helpers"],props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated"],computed:{$config(){return this.element.getConfig()},$html(){const t=this.$config.patternMatch||/\$\{(.+?)\}/g,{convertString:e}=this.helpers.qUtilities;return e(this.$config.html,t,this.state)},isReady(){return this.loadingCount<=0&&this.controllerReady}},created(){this.controllerReady&&this.init()},methods:{init(){this.element.onCreated({component:this}),this.$emit("onCreated")},getClass(t){return t.css||""}}},Ot=["innerHTML"],xt={key:1};function Qt(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-html q-widget-adapters-q-html __element __adapter __html",s.getClass(n.element)])},[s.$html&&s.isReady?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__html",innerHTML:s.$html},null,8,Ot)):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",xt,[r.createCommentVNode(" loading ")]))],2)}const Dt=m(Lt,[["render",Qt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QHtml.vue"]]),Vt={name:"q-widget-elements-adapters-q-import",props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated"],data(){return{elementState:{}}},computed:{$additionalListHeaders(){return this.$config.additionalListHeaders||[]},$config(){return this.element.getConfig()},$label(){return this.$config.label},$templateUrl(){return this.$config.templateUrl},elementHandlers(){return this.element.getHandlers()},isReady(){return this.loadingCount<=0&&this.controllerReady}},created(){this.controllerReady&&this.init()},methods:{init(){this.element.onCreated({component:this}),this.$emit("onCreated")},formatRowData(t){return this.elementHandlers.formatRowData(t)},getClass(t){return t.css||""},setElementState(t){this.elementState={...this.elementState,...t}},showError(t={}){const{payload:e}=t;return this.elementHandlers.showError({payload:e,state:{...this.state,...this.elementState}})},showSuccess({payload:t}){return this.elementHandlers.showSuccess({payload:t,state:{...this.state,...this.elementState}})},validationHandler({payload:t}){return this.elementHandlers.validationHandler({payload:t,state:this.state,setElementState:this.setElementState})}}},Ft={key:1};function Pt(t,e,n,o,i,s){const l=r.resolveComponent("q-import",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-import q-widget-adapters-q-import __element __adapter",s.getClass(n.element)])},[s.isReady?(r.openBlock(),r.createBlock(l,{key:0,additionalListHeaders:s.$additionalListHeaders,formatRowData:s.formatRowData,label:s.$label,showError:s.showError,showSuccess:s.showSuccess,templateUrl:s.$templateUrl,validationHandler:s.validationHandler},null,8,["additionalListHeaders","formatRowData","label","showError","showSuccess","templateUrl","validationHandler"])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",Ft,e[0]||(e[0]=[r.createElementVNode("div",{class:"import __loading-box"},[r.createElementVNode("div",{class:"skeleton"},[r.createElementVNode("div",{class:"skeleton__tr"},[r.createElementVNode("div",{class:"skeleton__td"})])])],-1)])))],2)}const Ut=m(Vt,[["render",Pt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QImport.vue"]]),Kt={name:"q-widget-elements-adapters-q-label",props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated"],computed:{$config(){return this.element.getConfig()},$label(){return this.$config.label||""},isReady(){return this.loadingCount<=0&&this.controllerReady}},created(){this.controllerReady&&this.init()},methods:{init(){this.element.onCreated({component:this}),this.$emit("onCreated")},getClass(t){return t.css||""}}},jt={key:0},It={key:1};function zt(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-label q-widget-adapters-q-label __element __label",s.getClass(n.element)])},[s.$label&&s.isReady?(r.openBlock(),r.createElementBlock("h2",jt,r.toDisplayString(s.$label),1)):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",It))],2)}const Tt=m(Kt,[["render",zt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QLabel.vue"]]),Wt={name:"q-widget-elements-adapters-q-list",inject:["helpers"],props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],data(){return{listRows:[],paginatorLayout:null,ready:!1}},computed:{$config(){return this.element.getConfig(this.helpers)},$converter(){return this.$config.converter},$css(){return this.$config.css},$eventName(){return this.$config.eventName||{}},$listBulkAction(){return this.$config.bulkAction||{}},$listHeaders(){return this.$config.headers||[]},$listSortBys(){return this.$config.listSortBys||[]},$listShowFooter(){return this.$config.listShowFooter||!1},$listStyle(){return this.$config.listStyle||"q-list-table"},$noDataMessage(){return this.$config.noDataMessage||""},isReady(){return this.loadingCount<=0&&this.controllerReady},listSortKeys(){return this.state.qSorterKeys||[]},rows(){return this.state.rows||[]}},created(){this.controllerReady&&this.init()},methods:{init(){this.listRows=this.rows.map(this.$converter),this.element.onCreated({component:this}),this.$emit("onCreated"),this.ready=!0},converter(t){return t},getClass(t){return t.css||""},onClickList(t){const{action:e,qRow:n,row:o}=t,{qListButtonType:i}=e,s={eventName:i||"onListClick",payload:t};this.$emit("onEvent",s)},onClickListBulk(t){const{action:e,qRows:n,rows:o}=t,{qListButtonType:i}=e,s={eventName:i||"onListClickBulk",payload:t};this.$emit("onEvent",s)},onListHeaderClick(t){const{key:e}=t.header;if(F(e,this.$listSortBys)){const o=Mt(this.listSortKeys,e),i=Gt(this.$listSortBys,o),s={eventName:this.$eventName.onListClickHeader||"onListClickHeader",payload:{qSorterKeys:o,qSorter:i}};this.$emit("onEvent",s)}}}};function F(t,e){return t?e.find(n=>{const{key:o}=n;return t===o}):null}function Mt(t,e){let n=!1;const o=t.map(i=>{const{by:s,direction:l}=i;if(e===s){n=!0;const a=typeof l<"u"?Number(l)===1?-1:Number(l)===-1?0:1:1;return{...i,direction:a}}return i});return n?o.filter(i=>i.direction!==0):[...t,{by:e,direction:1}]}function Gt(t,e){return e.reduce((n,o)=>{const{by:i,direction:s}=o,l=F(i,t),{value:a=[]}=l;if(!l)return n;const u=a.map(c=>({...c,direction:s}));return n.push(...u),n},[])}const Jt={key:1};function Yt(t,e,n,o,i,s){const l=r.resolveComponent("q-list",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-list q-widget-adapters-q-list __element __adapter __list",s.getClass(n.element)])},[s.isReady&&i.ready?(r.openBlock(),r.createBlock(l,{key:0,bulkAction:s.$listBulkAction,css:s.$css,headers:s.$listHeaders,listStyle:s.$listStyle,noDataMessage:s.$noDataMessage,rows:i.listRows,showFooter:s.$listShowFooter,sortBys:s.$listSortBys,sortStatus:s.listSortKeys,onClick:s.onClickList,onOnClickBulk:s.onClickListBulk,onOnListHeaderClick:s.onListHeaderClick},null,8,["bulkAction","css","headers","listStyle","noDataMessage","rows","showFooter","sortBys","sortStatus","onClick","onOnClickBulk","onOnListHeaderClick"])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",Jt,e[0]||(e[0]=[r.createStaticVNode('<div class="__loading-box"><div class="skeleton"><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__hr"></div><div class="skeleton__section skeleton__section--table"><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div></div></div></div>',1)])))],2)}const Xt=m(Wt,[["render",Yt],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QList.vue"]]),Zt={name:"q-widget-elements-adapters-q-paginator",props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],data(){return{isPaginator:!1,paginatorLayout:null}},computed:{$config(){return this.element.getConfig()},$controlLabel(){return this.$config.controlLabel},$eventName(){return this.$config.eventName||{}},$paginatorLayout(){return this.$config.layout},$paginatorSizeOptions(){return this.$paginatorLayout.pageSizeOptions||[]},currentPage(){return this.state.currentPage},currentPageSize(){return this.state.currentPageSize},currentPageSizeOptionsIndex(){return this.$paginatorSizeOptions.indexOf(this.currentPageSize)},initPage(){return this.currentPage>=0?this.currentPage:this.$paginatorLayout.initPage},isReady(){return this.loadingCount<=0&&this.controllerReady},pageSizeOptionsIndex(){return this.currentPageSizeOptionsIndex>=0?this.currentPageSizeOptionsIndex:(this.onChangeRecPerPage(this.$paginatorSizeOptions[this.$paginatorLayout.pageSizeOptionsIdx],this.initPage),this.$paginatorLayout.pageSizeOptionsIndex)},totalRecords(){return this.state.totalRecords}},created(){this.controllerReady&&this.init()},mounted(){},methods:{init(){this.paginatorLayout={...this.$paginatorLayout,initPage:this.initPage,pageSizeOptionsIndex:this.pageSizeOptionsIndex},this.isPaginator=!0,this.element.onCreated({component:this}),this.$emit("onCreated")},getClass(t){return t.css||""},onChangePageIdx(t){if(t!==this.currentPage){const n={eventName:this.$eventName.onChangePageIdx||"onChangePageIdx",payload:{currentPage:t}};this.$emit("onEvent",n)}},onChangeRecPerPage(t,e){const o={eventName:this.$eventName.onChangeRecPerPage||"onChangeRecPerPage",payload:{currentPageSize:t,currentPage:e}};this.$emit("onEvent",o)}}},en={key:1};function tn(t,e,n,o,i,s){const l=r.resolveComponent("q-paginator",!0);return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-paginator q-widget-adapters-q-paginator __element __adapter __paginator",s.getClass(n.element)])},[i.isPaginator&&s.isReady?(r.openBlock(),r.createBlock(l,{key:0,controlLabel:s.$controlLabel,layout:i.paginatorLayout,total:s.totalRecords,onChangeCurrentPage:s.onChangePageIdx,onChangePageSize:s.onChangeRecPerPage},null,8,["controlLabel","layout","total","onChangeCurrentPage","onChangePageSize"])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",en,e[0]||(e[0]=[r.createStaticVNode('<div class="paginator __loading-box"><div class="skeleton"><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div></div></div>',1)])))],2)}const nn=m(Zt,[["render",tn],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QPaginator.vue"]]),sn={name:"q-widget-elements-adapters-q-tab",props:{controllerReady:{type:Boolean,default:!1},element:{type:Object,default:()=>({})},elementName:{type:String,default:""},loadingCount:{type:Number,default:0},state:{type:Object,default:()=>({})}},emits:["onCreated","onEvent"],data(){return{active:{},renderKey:0,tabLayout:[]}},computed:{$config(){return this.element.getConfig()},$eventName(){return this.$config.eventName||{}},$tabLayout(){return this.$config.layout||[]},activeKey(){return this.active.key},isReady(){return this.loadingCount<=0&&this.controllerReady}},created(){this.controllerReady&&this.init()},methods:{init(){this.tabLayout=[...this.$tabLayout],this.active=this.state.active||this.tabLayout[0]||{},this.element.onCreated({component:this,payload:{tabLayout:this.tabLayout}}),this.$emit("onCreated")},getClass(t){return t.css||""},onChangeTab(t){const n={eventName:this.$eventName.onChangeTab||"onTabChange",payload:{active:t}};this.$emit("onEvent",n)}}},rn={key:0,class:"__tabs __flex"},on=["href"],ln=["onClick"],an={key:1};function cn(t,e,n,o,i,s){return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["q-widget-elements-adapters-q-tab q-widget-adapters-q-tab __element __adapter",s.getClass(n.element)])},[s.isReady?(r.openBlock(),r.createElementBlock("div",rn,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(i.tabLayout,(l,a)=>(r.openBlock(),r.createElementBlock("div",{key:a,class:r.normalizeClass(["__pointer __tab",s.activeKey===l.key?"__active":""])},[l.url?(r.openBlock(),r.createElementBlock("a",{key:0,href:l.url},r.toDisplayString(l.label)+r.toDisplayString(Number.isNaN(Number(l.total))?"":`(${Number(l.total)})`),9,on)):r.createCommentVNode("v-if",!0),l.url?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",{key:1,onClick:u=>s.onChangeTab(l)},r.toDisplayString(l.label)+r.toDisplayString(Number.isNaN(Number(l.total))?"":`(${Number(l.total)})`),9,ln))],2))),128))])):r.createCommentVNode("v-if",!0),s.isReady?r.createCommentVNode("v-if",!0):(r.openBlock(),r.createElementBlock("div",an,e[0]||(e[0]=[r.createStaticVNode('<div class="__loading-box"><div class="skeleton"><div class="skeleton__tr"><div class="skeleton__td"></div><div class="skeleton__td"></div><div class="skeleton__td"></div></div></div></div>',1)])))],2)}const dn={name:"q-widget-elements-element",components:{QWidgetQButtonElement:kt,QWidgetQFormElement:Bt,QWidgetQGridElement:At,QWidgetQHtmlElement:Dt,QWidgetQImportElement:Ut,QWidgetQLabelElement:Tt,QWidgetQListElement:Xt,QWidgetQPaginatorElement:nn,QWidgetQTabElement:m(sn,[["render",cn],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Adapters/QTab.vue"]])},props:{controllerReady:{type:Boolean,default:!1},node:{type:Object,default:()=>({})},loadingCount:{type:Number,default:0}},emits:["onEvent","onElementCreated"],computed:{elementName(){return this.element.getElementName()},element(){return this.node},state(){return this.element.getState()}},methods:{factoryInit(t){return t instanceof h.ElementQButton?"q-widget-q-button-element":t instanceof h.ElementQForm?"q-widget-q-form-element":t instanceof h.ElementQGrid?"q-widget-q-grid-element":t instanceof h.ElementQHtml?"q-widget-q-html-element":t instanceof h.ElementQImport?"q-widget-q-import-element":t instanceof h.ElementQLabel?"q-widget-q-label-element":t instanceof h.ElementQList?"q-widget-q-list-element":t instanceof h.ElementQPaginator?"q-widget-q-paginator-element":t instanceof h.ElementQTab?"q-widget-q-tab-element":""},onEvent(t){this.$emit("onEvent",{...t,element:this.element})},onElementCreated(){this.element.isCreated&&this.$emit("onElementCreated",[this.element])}}};function un(t,e,n,o,i,s){return r.openBlock(),r.createBlock(r.resolveDynamicComponent(s.factoryInit(n.node)),{controllerReady:n.controllerReady,element:n.node,elementName:s.elementName,loadingCount:n.loadingCount,state:s.state,onOnCreated:s.onElementCreated,onOnEvent:s.onEvent},null,40,["controllerReady","element","elementName","loadingCount","state","onOnCreated","onOnEvent"])}const mn=Object.freeze(Object.defineProperty({__proto__:null,default:m(dn,[["render",un],["__file","/Users/questwork/Developer/qw.vue.q.widget/src/components/Elements/Element.vue"]])},Symbol.toStringTag,{value:"Module"}));return {QWidget:w};Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
No third parties dependencies
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function saveState({
|
|
2
|
+
controller,
|
|
3
|
+
state,
|
|
4
|
+
saveControllerState,
|
|
5
|
+
}) {
|
|
6
|
+
const { saveStateKeys = [] } = controller
|
|
7
|
+
const data = saveStateKeys.reduce((acc, k) => ({
|
|
8
|
+
...acc,
|
|
9
|
+
...getObjectByKeys({ keys: k.split('.'), obj: state })
|
|
10
|
+
}), {})
|
|
11
|
+
return saveControllerState({ data })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getObjectByKeys({ keys, obj }) {
|
|
15
|
+
const firstKey = keys.shift()
|
|
16
|
+
return {
|
|
17
|
+
[firstKey]: (keys.length === 0) ? obj[firstKey] : getObjectByKeys({ keys, obj: obj[firstKey] })
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
saveState
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
saveState
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function showError({
|
|
2
|
+
component, message, modalConfig = {}
|
|
3
|
+
}) {
|
|
4
|
+
const { countdown, label, title, canClose = true } = modalConfig
|
|
5
|
+
const modal = {
|
|
6
|
+
body: [
|
|
7
|
+
{
|
|
8
|
+
customComponentName: 'q-modal-region-tool-html',
|
|
9
|
+
html: message
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
countdown,
|
|
13
|
+
label,
|
|
14
|
+
onClose: canClose ? () => {
|
|
15
|
+
component.modal = null
|
|
16
|
+
} : null,
|
|
17
|
+
title: title || 'Error'
|
|
18
|
+
}
|
|
19
|
+
component.modal = modal
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
showError
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
showError
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Handlers } from './handlers'
|
|
2
|
+
|
|
3
|
+
function configHandler({ config, configPermissions = [], type }) {
|
|
4
|
+
const _config = configPermissions.reduce((acc, item) => {
|
|
5
|
+
const handler = _elementConfigHandlerFactory(type)
|
|
6
|
+
if (!handler || typeof handler.exec !== 'function') {
|
|
7
|
+
console.log('no config handler')
|
|
8
|
+
return acc
|
|
9
|
+
}
|
|
10
|
+
const { key, value } = item
|
|
11
|
+
return handler.exec({ config: acc, keys: key.split('.'), permissions: value })
|
|
12
|
+
}, config)
|
|
13
|
+
return _config
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function _elementConfigHandlerFactory(type) {
|
|
17
|
+
return Handlers[type] || null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
configHandler
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
configHandler
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class ButtonsHandler {
|
|
2
|
+
static exec({ config, keys, permissions }) {
|
|
3
|
+
if (!Array.isArray(config)) {
|
|
4
|
+
console.log('can not handle these buttons')
|
|
5
|
+
}
|
|
6
|
+
const firstKey = keys.shift()
|
|
7
|
+
if (keys.length !== 0) {
|
|
8
|
+
console.log(`can not handle ${keys.join('.')}`)
|
|
9
|
+
}
|
|
10
|
+
return _handler({ buttons: config, key: firstKey, permissions })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _handler({ buttons, key, permissions }) {
|
|
15
|
+
return buttons.map((action) => {
|
|
16
|
+
if (_isCurrentItem(key, action)) {
|
|
17
|
+
const _permissions = action.permissions || []
|
|
18
|
+
return {
|
|
19
|
+
...action,
|
|
20
|
+
permissions: [
|
|
21
|
+
..._permissions,
|
|
22
|
+
...permissions
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return action
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _isCurrentItem(key, item) {
|
|
31
|
+
const { buttonType, id, label } = item
|
|
32
|
+
return key === id || key === label || key === buttonType
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
ButtonsHandler
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
ButtonsHandler
|
|
41
|
+
}
|
package/lib/helpers/utilities/configHandler/handlers/elementQForm/elementQFormConfigHandler.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonsHandler } from './buttonsHandler'
|
|
2
|
+
import { LayoutHandler } from './layoutHandler'
|
|
3
|
+
|
|
4
|
+
class ElementQFormConfigHandler {
|
|
5
|
+
static exec({ config, keys, permissions }) {
|
|
6
|
+
const firstKey = keys.shift()
|
|
7
|
+
let handler = null
|
|
8
|
+
switch (firstKey) {
|
|
9
|
+
case ('buttons'): {
|
|
10
|
+
handler = ButtonsHandler
|
|
11
|
+
break
|
|
12
|
+
}
|
|
13
|
+
case ('layout'): {
|
|
14
|
+
handler = LayoutHandler
|
|
15
|
+
break
|
|
16
|
+
}
|
|
17
|
+
default: {
|
|
18
|
+
handler = null
|
|
19
|
+
break
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!handler || typeof handler.exec !== 'function') {
|
|
23
|
+
return config
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...config,
|
|
27
|
+
[firstKey]: handler.exec({ config: config[firstKey], keys: [...keys], permissions })
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
ElementQFormConfigHandler
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ElementQFormConfigHandler
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ElementQFormConfigHandler } from './elementQFormConfigHandler'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class LayoutHandler {
|
|
2
|
+
static exec({ config, keys, permissions }) {
|
|
3
|
+
return _handler({ layout: config, keys, permissions })
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function _handler({ layout, keys, permissions }) {
|
|
8
|
+
const firstKey = keys[0]
|
|
9
|
+
const { children, permissions: _permissions } = layout
|
|
10
|
+
if (_isCurrentItem(firstKey, layout)) {
|
|
11
|
+
keys.shift()
|
|
12
|
+
if (keys.length === 0) {
|
|
13
|
+
return {
|
|
14
|
+
...layout,
|
|
15
|
+
permissions: [
|
|
16
|
+
..._permissions || [],
|
|
17
|
+
...permissions
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(children)) {
|
|
22
|
+
return {
|
|
23
|
+
...layout,
|
|
24
|
+
children: children.map((child) => (
|
|
25
|
+
_handler({ layout: child, keys: [...keys], permissions })
|
|
26
|
+
))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
console.log(`can not handle ${keys.join('.')}`)
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(children)) {
|
|
32
|
+
return {
|
|
33
|
+
...layout,
|
|
34
|
+
children: children.map((child) => (
|
|
35
|
+
_handler({ layout: child, keys: [...keys], permissions })
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// console.log(`can not handle ${keys.join('.')}`)
|
|
40
|
+
return layout
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _isCurrentItem(key, item) {
|
|
44
|
+
const { id, name } = item
|
|
45
|
+
return key === id || key === name
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
LayoutHandler
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
LayoutHandler
|
|
54
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class ActionsHandler {
|
|
2
|
+
static exec({ config, keys, permissions }) {
|
|
3
|
+
if (!Array.isArray(config)) {
|
|
4
|
+
console.log('can not handle these actions')
|
|
5
|
+
}
|
|
6
|
+
const firstKey = keys.shift()
|
|
7
|
+
if (keys.length !== 0) {
|
|
8
|
+
console.log(`can not handle ${keys.join('.')}`)
|
|
9
|
+
}
|
|
10
|
+
return _handler({ actions: config, key: firstKey, permissions })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _handler({ actions, key, permissions }) {
|
|
15
|
+
return actions.map((action) => {
|
|
16
|
+
if (_isCurrentItem(key, action)) {
|
|
17
|
+
const _permissions = action.permissions || []
|
|
18
|
+
return {
|
|
19
|
+
...action,
|
|
20
|
+
permissions: [
|
|
21
|
+
..._permissions,
|
|
22
|
+
...permissions
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return action
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _isCurrentItem(key, item) {
|
|
31
|
+
const { id, label } = item
|
|
32
|
+
return key === id || key === label
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
ActionsHandler
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
ActionsHandler
|
|
41
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class BulkActionHandler {
|
|
2
|
+
static exec({ config, keys, permissions }) {
|
|
3
|
+
const firstKey = keys.shift()
|
|
4
|
+
switch (firstKey) {
|
|
5
|
+
case ('actions'): {
|
|
6
|
+
return {
|
|
7
|
+
...config,
|
|
8
|
+
actions: _handler({ actions: config[firstKey], keys, permissions })
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
default: {
|
|
12
|
+
return config
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _handler({ actions, keys, permissions }) {
|
|
19
|
+
if (!Array.isArray(actions)) {
|
|
20
|
+
console.log('can not handle these actions')
|
|
21
|
+
}
|
|
22
|
+
const firstKey = keys.shift()
|
|
23
|
+
if (keys.length !== 0) {
|
|
24
|
+
console.log(`can not handle ${keys.join('.')}`)
|
|
25
|
+
return actions
|
|
26
|
+
}
|
|
27
|
+
return actions.map((action) => {
|
|
28
|
+
if (_isCurrentItem(firstKey, action)) {
|
|
29
|
+
const _permissions = action.permissions || []
|
|
30
|
+
return {
|
|
31
|
+
...action,
|
|
32
|
+
permissions: [
|
|
33
|
+
..._permissions,
|
|
34
|
+
...permissions
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return action
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _isCurrentItem(key, item) {
|
|
43
|
+
const { id, label } = item
|
|
44
|
+
return key === id || key === label
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
BulkActionHandler
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
BulkActionHandler
|
|
53
|
+
}
|
package/lib/helpers/utilities/configHandler/handlers/elementQList/elementQListConfigHandler.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ActionsHandler } from './actionsHandler'
|
|
2
|
+
import { BulkActionHandler } from './bulkActionHandler'
|
|
3
|
+
import { HeadersHandler } from './headersHandler'
|
|
4
|
+
|
|
5
|
+
class ElementQListConfigHandler {
|
|
6
|
+
static exec({ config, keys, permissions }) {
|
|
7
|
+
const firstKey = keys.shift()
|
|
8
|
+
let handler = null
|
|
9
|
+
switch (firstKey) {
|
|
10
|
+
case ('actions'): {
|
|
11
|
+
handler = ActionsHandler
|
|
12
|
+
break
|
|
13
|
+
}
|
|
14
|
+
case ('bulkAction'): {
|
|
15
|
+
handler = BulkActionHandler
|
|
16
|
+
break
|
|
17
|
+
}
|
|
18
|
+
case ('headers'): {
|
|
19
|
+
handler = HeadersHandler
|
|
20
|
+
break
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
handler = null
|
|
24
|
+
break
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!handler || typeof handler.exec !== 'function') {
|
|
28
|
+
return config
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...config,
|
|
32
|
+
[firstKey]: handler.exec({ config: config[firstKey], keys: [...keys], permissions })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
ElementQListConfigHandler
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
ElementQListConfigHandler
|
|
43
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class HeadersHandler {
|
|
2
|
+
static exec({ config, keys, permissions }) {
|
|
3
|
+
if (!Array.isArray(config)) {
|
|
4
|
+
console.log('can not handle these actions')
|
|
5
|
+
}
|
|
6
|
+
return _handler({ headers: config, keys, permissions })
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function _handler({ headers, keys, permissions }) {
|
|
11
|
+
const firstKey = keys.shift()
|
|
12
|
+
return headers.map((header) => {
|
|
13
|
+
if (_isCurrentItem(firstKey, header)) {
|
|
14
|
+
const { permissions: _permissions, children } = header
|
|
15
|
+
if (keys.length !== 0) {
|
|
16
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
17
|
+
return {
|
|
18
|
+
...header,
|
|
19
|
+
children: _handler({ headers: children, keys, permissions })
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
console.log(`can not handle ${keys.join('.')}`)
|
|
23
|
+
return header
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...header,
|
|
27
|
+
permissions: [
|
|
28
|
+
..._permissions || [],
|
|
29
|
+
...permissions
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return header
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _isCurrentItem(key, item) {
|
|
38
|
+
const { id, label, key: headerKey } = item
|
|
39
|
+
return key === id || key === label || key === headerKey
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
HeadersHandler
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
HeadersHandler
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ElementQListConfigHandler } from './elementQListConfigHandler'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElementQFormConfigHandler } from './elementQForm'
|
|
2
|
+
import { ElementQListConfigHandler } from './elementQList'
|
|
3
|
+
|
|
4
|
+
const Handlers = {
|
|
5
|
+
ElementQForm: ElementQFormConfigHandler,
|
|
6
|
+
ElementQList: ElementQListConfigHandler
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
...Handlers,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
Handlers
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { configHandler } from './configHandler'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setId } from './setId'
|