diff --git a/CONFIG.md b/CONFIG.md index bf00f38..ccb3565 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -253,6 +253,24 @@ class MyCustomRule extends ncformCommon.ValidationRule { this.$ncformAddRule({name: 'myCustom', rule: MyCustomRule}); ``` +- $ncformAllRules() + +Get all registered check rules of ncform + +``` +// Demo code: +const allRules = this.$ncformAllRules(); +``` + +- $ncformAllWidgets() + +Get all registered widgets of ncform + +``` +// Demo code: +const allWidgets = this.$ncformAllWidgets(); +``` + ## ncform event - submit diff --git a/CONFIG_CN.md b/CONFIG_CN.md index e6856ca..3c75f52 100644 --- a/CONFIG_CN.md +++ b/CONFIG_CN.md @@ -254,6 +254,24 @@ class MyCustomRule extends ncformCommon.ValidationRule { this.$ncformAddRule({name: 'myCustom', rule: MyCustomRule}); ``` +- $ncformAllRules() + +取得ncform所有注册的校验规则 + +``` +// Demo code: +const allRules = this.$ncformAllRules(); +``` + +- $ncformAllWidgets() + +取得ncform所有注册的表单组件 + +``` +// Demo code: +const allWidgets = this.$ncformAllWidgets(); +``` + ## ncform event - submit diff --git a/STD-COMP.md b/STD-COMP.md index 7b65fdc..0d0be55 100755 --- a/STD-COMP.md +++ b/STD-COMP.md @@ -266,7 +266,12 @@ If you don't like the cold text description, click on the [interactive version]( disableItemCollapse: false, // Whether to allow items to be folded itemCollapse: false, // Whether the item is folded by default addTxt: 'Add', // New display text - delAllTxt: 'Del All' // Delete all display text + delAllTxt: 'Del All', // Delete all display text + requiredDelConfirm: false, // Whether the deletion requires confirmation + delConfirmText: { // Delete confirmation text + item: '', + all: '' + }, } ``` @@ -280,7 +285,12 @@ If you don't like the cold text description, click on the [interactive version]( collapsed: false, // Whether to fold by default disableCollapse: false, // Whether to allow folding addTxt: 'Add', // New display text - delAllTxt: 'Del All' // Delete all display text + delAllTxt: 'Del All', // Delete all display text + requiredDelConfirm: false, // Whether the deletion requires confirmation + delConfirmText: { // Delete confirmation text + item: '', + all: '' + }, } ``` @@ -293,5 +303,10 @@ If you don't like the cold text description, click on the [interactive version]( tabPosition: 'top', // Optional value:[left | top] collapsed: false, // Whether to fold by default disableCollapse: false, // Whether to allow folding + requiredDelConfirm: false, // Whether the deletion requires confirmation + delConfirmText: { // Delete confirmation text + item: '', + all: '' + }, } ``` diff --git a/STD-COMP_CN.md b/STD-COMP_CN.md index 2245b90..ffbd305 100644 --- a/STD-COMP_CN.md +++ b/STD-COMP_CN.md @@ -266,7 +266,12 @@ disableItemCollapse: false, // 是否允许项折叠 itemCollapse: false, // 项是否默认折叠 addTxt: 'Add', // 新建文字 - delAllTxt: 'Del All' // 删除全部文字 + delAllTxt: 'Del All', // 删除全部文字 + requiredDelConfirm: false, // 是否需要删除确认 + delConfirmText: { // 删除确认文本 + item: '', + all: '' + }, } ``` @@ -280,7 +285,12 @@ collapsed: false, // 是否默认折叠 disableCollapse: false, // 是否允许折叠 addTxt: 'Add', // 新建文字 - delAllTxt: 'Del All' // 删除全部文字 + delAllTxt: 'Del All', // 删除全部文字 + requiredDelConfirm: false, // 是否需要删除确认 + delConfirmText: { // 删除确认文本 + item: '', + all: '' + }, } ``` @@ -293,5 +303,10 @@ tabPosition: 'top', // 可选值:left / top collapsed: false, // 是否默认折叠 disableCollapse: false, // 是否允许折叠 + requiredDelConfirm: false, // 是否需要删除确认 + delConfirmText: { // 删除确认文本 + item: '', + all: '' + }, } ``` diff --git a/packages/ncform-common/src/mixins/vue/layout-array-mixin.js b/packages/ncform-common/src/mixins/vue/layout-array-mixin.js index e82cbad..0cd3623 100755 --- a/packages/ncform-common/src/mixins/vue/layout-array-mixin.js +++ b/packages/ncform-common/src/mixins/vue/layout-array-mixin.js @@ -68,6 +68,11 @@ export default { disableDel: false, addTxt: "", delAllTxt: "", + requiredDelConfirm: false, + delConfirmText: { + item: '', + all: '' + }, }, i18n: {}, }; @@ -125,12 +130,45 @@ export default { } }, - delItem(idx) { - this.schema.value.splice(idx, 1); + delItem(idx, requiredConfirm, confirmText) { + if (this.$confirm) { // use element-ui + if (requiredConfirm) { + this.$confirm(confirmText, '', { + type: 'warning' + }).then(() => { + this.schema.value.splice(idx, 1); + }) + } else { + this.schema.value.splice(idx, 1); + } + } else { + if (requiredConfirm) { + window.confirm(confirmText) && this.schema.value.splice(idx, 1); + } else { + this.schema.value.splice(idx, 1); + } + } }, - delAllItems() { - this.schema.value = []; + delAllItems(requiredConfirm, confirmText) { + if (this.$confirm) { // use element-ui + if (requiredConfirm) { + this.$confirm(confirmText, '', { + type: 'warning' + }).then(() => { + this.schema.value = []; + }) + } else { + this.schema.value = []; + } + } else { + if (requiredConfirm) { + window.confirm(confirmText) && (this.schema.value = []); + } else { + this.schema.value = []; + } + } + }, itemUp(idx) { diff --git a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/array.spec.js b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/array.spec.js index a53696c..b0bfdfc 100644 --- a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/array.spec.js +++ b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/array.spec.js @@ -42,6 +42,20 @@ context('Array', () => { disableItemCollapse: true } } + }, + users3: { + type: 'array', + value: [ + 'daniel', 'sarah' + ], + items: { + type: 'string' + }, + ui: { + widgetConfig: { + requiredDelConfirm: true + } + } } } }; @@ -50,6 +64,8 @@ context('Array', () => { .invoke('setValue', JSON.stringify(formSchema, null, 2)); common.startRun(); + cy.get('body').as('body'); + cy.get('.previewArea').within(() => { // Declare action elements cy.get('legend') @@ -97,6 +113,22 @@ context('Array', () => { cy.get('button:contains("Delete All")').should('not.exist'); cy.get('.el-icon-remove').should('not.exist'); }); + + cy.get('legend') + .contains('users3') + .parent() + .within(() => { + cy.get('.el-icon-remove').eq(0).click(); + cy.get('@body').find('.el-message-box__message').should('have.text', 'Are you sure to delete this item?'); + cy.get('@body').find('.el-message-box__btns .el-button--primary').click(); + cy.get('input').its('length').should('equal', 1); + + cy.get('button:contains("Delete All")').click(); + cy.get('@body').find('.el-message-box__message').should('have.text', 'Are you sure to delete all?'); + cy.get('@body').find('.el-message-box__btns .el-button--primary').click(); + cy.get('input').should('not.exist'); + }); + // common.submitForm(); }); }); diff --git a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/table.spec.js b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/table.spec.js index 5a6cb47..c2fe9e1 100644 --- a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/table.spec.js +++ b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/table.spec.js @@ -42,6 +42,25 @@ context('Table', () => { disableCollapse: true, } } + }, + users3: { + type: 'array', + value: [ + 'daniel', 'sarah' + ], + items: { + type: 'string' + }, + ui: { + widget: 'array-table', + widgetConfig: { + requiredDelConfirm: true, + delConfirmText: { + item: 'Sure to delete item', + all: 'Sure to delete all' + }, + } + } } } }; @@ -50,6 +69,8 @@ context('Table', () => { .invoke('setValue', JSON.stringify(formSchema, null, 2)); common.startRun(); + cy.get('body').as('body'); + cy.get('.previewArea').within(() => { // Declare action elements cy.get('legend') @@ -89,6 +110,21 @@ context('Table', () => { cy.get('button:contains("Delete All")').should('not.exist'); cy.get('.el-icon-remove').should('not.exist'); }); + + cy.get('legend') + .contains('users3') + .parent() + .within(() => { + cy.get('.el-icon-remove').eq(0).click(); + cy.get('@body').find('.el-message-box__message').should('have.text', 'Sure to delete item'); + cy.get('@body').find('.el-message-box__btns .el-button--primary').click(); + cy.get('input').its('length').should('equal', 1); + + cy.get('button:contains("Delete All")').click(); + cy.get('@body').find('.el-message-box__message').should('have.text', 'Sure to delete all'); + cy.get('@body').find('.el-message-box__btns .el-button--primary').click(); + cy.get('input').should('not.exist'); + }); // common.submitForm(); }); }); diff --git a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/tabs.spec.js b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/tabs.spec.js index 9290e05..3c19c5f 100644 --- a/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/tabs.spec.js +++ b/packages/ncform-e2e/ncform-theme-elementui/cypress/integration/examples/tabs.spec.js @@ -41,6 +41,24 @@ context('Tabs', () => { disableCollapse: true, } } + }, + users3: { + type: 'array', + value: [ + 'daniel', 'sarah' + ], + items: { + type: 'string' + }, + ui: { + widget: 'array-tabs', + widgetConfig: { + requiredDelConfirm: true, + delConfirmText: { + item: 'Sure to delete item' + }, + } + } } } }; @@ -49,39 +67,50 @@ context('Tabs', () => { .invoke('setValue', JSON.stringify(formSchema, null, 2)); common.startRun(); + cy.get('body').as('body'); + cy.get('.previewArea').within(() => { // Declare action elements cy.get('legend') - .contains('users1') - .parent() - .within(() => { - cy.get('legend').next().should('not.be.visible'); - cy.get('legend').click(); - cy.get('legend').next().should('be.visible'); + .contains('users1') + .parent() + .within(() => { + cy.get('legend').next().should('not.be.visible'); + cy.get('legend').click(); + cy.get('legend').next().should('be.visible'); - cy.get('.el-icon-plus').click() - cy.get('.el-tabs__item').its('length').should('equal', 2); + cy.get('.el-icon-plus').click() + cy.get('.el-tabs__item').its('length').should('equal', 2); - cy.get('input').eq(0).type('daniel') - cy.get('.el-tabs__item').eq(1).click(); - cy.get('input').eq(1).type('sarah') + cy.get('input').eq(0).type('daniel') + cy.get('.el-tabs__item').eq(1).click(); + cy.get('input').eq(1).type('sarah') - cy.get('.el-icon-close:visible').click(); - cy.get('.el-tabs__item').its('length').should('equal', 1); - - }); + cy.get('.el-icon-close:visible').click(); + cy.get('.el-tabs__item').its('length').should('equal', 1); + }); cy.get('legend') - .contains('users2') - .parent() - .within(() => { - cy.get('legend').next().should('be.visible'); - cy.get('legend').click(); - cy.get('legend').next().should('be.visible'); + .contains('users2') + .parent() + .within(() => { + cy.get('legend').next().should('be.visible'); + cy.get('legend').click(); + cy.get('legend').next().should('be.visible'); - cy.get('.el-icon-plus').should('not.exist'); - cy.get('.el-icon-close').should('not.exist'); - }); + cy.get('.el-icon-plus').should('not.exist'); + cy.get('.el-icon-close').should('not.exist'); + }); + + cy.get('legend') + .contains('users3') + .parent() + .within(() => { + cy.get('.el-icon-close:visible').click(); + cy.get('@body').find('.el-message-box__message').should('have.text', 'Sure to delete item'); + cy.get('@body').find('.el-message-box__btns .el-button--primary').click(); + cy.get('.el-tabs__item').its('length').should('equal', 1); + }); // common.submitForm(); }); }); diff --git a/packages/ncform-e2e/ncform/cypress/integration/examples/others.js b/packages/ncform-e2e/ncform/cypress/integration/examples/others.js index 56af222..863f37f 100644 --- a/packages/ncform-e2e/ncform/cypress/integration/examples/others.js +++ b/packages/ncform-e2e/ncform/cypress/integration/examples/others.js @@ -80,4 +80,11 @@ context('Others', () => { }) }) + it('$ncformAllWidgets and $ncformAllRules()', () => { + cy.window().then(win => { + expect(win.Vue.prototype.$ncformAllRules()).to.deep.equal(["contains", "exclusiveMinimum", "ipv6", "maximum", "minimum", "required", "dateTime", "hostname", "maxItems", "minItems", "multipleOf", "tel", "email", "maxLength", "minLength", "number", "uniqueItems", "exclusiveMaximum", "ipv4", "maxProperties", "minProperties", "pattern", "url", "ajax"]); + expect(win.Vue.prototype.$ncformAllWidgets()).to.deep.equal(["object", "array", "array-table", "input"]); + }) + }) + }) diff --git a/packages/ncform-show/examples/components/playground/index.html b/packages/ncform-show/examples/components/playground/index.html index 01a45cd..9112f88 100755 --- a/packages/ncform-show/examples/components/playground/index.html +++ b/packages/ncform-show/examples/components/playground/index.html @@ -30,7 +30,7 @@ - + diff --git a/packages/ncform-show/examples/components/schema-gen/index.html b/packages/ncform-show/examples/components/schema-gen/index.html index f7eeaba..1a30509 100755 --- a/packages/ncform-show/examples/components/schema-gen/index.html +++ b/packages/ncform-show/examples/components/schema-gen/index.html @@ -36,7 +36,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/checkbox.html b/packages/ncform-theme-elementui/examples/control-comps/checkbox.html index 9453a4e..17f21ec 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/checkbox.html +++ b/packages/ncform-theme-elementui/examples/control-comps/checkbox.html @@ -42,7 +42,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/color-picker.html b/packages/ncform-theme-elementui/examples/control-comps/color-picker.html index 334a540..d49f9af 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/color-picker.html +++ b/packages/ncform-theme-elementui/examples/control-comps/color-picker.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/date-picker.html b/packages/ncform-theme-elementui/examples/control-comps/date-picker.html index 4b3ca63..3186e3b 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/date-picker.html +++ b/packages/ncform-theme-elementui/examples/control-comps/date-picker.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/input-number.html b/packages/ncform-theme-elementui/examples/control-comps/input-number.html index ba199fd..df8e3fa 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/input-number.html +++ b/packages/ncform-theme-elementui/examples/control-comps/input-number.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/input.html b/packages/ncform-theme-elementui/examples/control-comps/input.html index 58c9fc8..794b977 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/input.html +++ b/packages/ncform-theme-elementui/examples/control-comps/input.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/label.html b/packages/ncform-theme-elementui/examples/control-comps/label.html index ff9edd5..ff27c74 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/label.html +++ b/packages/ncform-theme-elementui/examples/control-comps/label.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/radio.html b/packages/ncform-theme-elementui/examples/control-comps/radio.html index ffdea33..dba35fa 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/radio.html +++ b/packages/ncform-theme-elementui/examples/control-comps/radio.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/rate.html b/packages/ncform-theme-elementui/examples/control-comps/rate.html index a2de9ec..05688f6 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/rate.html +++ b/packages/ncform-theme-elementui/examples/control-comps/rate.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/select.html b/packages/ncform-theme-elementui/examples/control-comps/select.html index 2f9a84e..e796f20 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/select.html +++ b/packages/ncform-theme-elementui/examples/control-comps/select.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/slider.html b/packages/ncform-theme-elementui/examples/control-comps/slider.html index 46a8247..569672d 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/slider.html +++ b/packages/ncform-theme-elementui/examples/control-comps/slider.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/textarea.html b/packages/ncform-theme-elementui/examples/control-comps/textarea.html index 3e178ca..ab42aff 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/textarea.html +++ b/packages/ncform-theme-elementui/examples/control-comps/textarea.html @@ -43,7 +43,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/control-comps/upload.html b/packages/ncform-theme-elementui/examples/control-comps/upload.html index 7fdeb1f..1162481 100755 --- a/packages/ncform-theme-elementui/examples/control-comps/upload.html +++ b/packages/ncform-theme-elementui/examples/control-comps/upload.html @@ -44,7 +44,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/debug/object.html b/packages/ncform-theme-elementui/examples/debug/object.html index 696eea2..fa69bf5 100644 --- a/packages/ncform-theme-elementui/examples/debug/object.html +++ b/packages/ncform-theme-elementui/examples/debug/object.html @@ -31,7 +31,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/debug/select.html b/packages/ncform-theme-elementui/examples/debug/select.html index 10f8555..7a7b78e 100755 --- a/packages/ncform-theme-elementui/examples/debug/select.html +++ b/packages/ncform-theme-elementui/examples/debug/select.html @@ -20,7 +20,7 @@ - + diff --git a/packages/ncform-theme-elementui/examples/layout-comps/array-table.html b/packages/ncform-theme-elementui/examples/layout-comps/array-table.html index 3cc101d..a396aee 100755 --- a/packages/ncform-theme-elementui/examples/layout-comps/array-table.html +++ b/packages/ncform-theme-elementui/examples/layout-comps/array-table.html @@ -54,7 +54,7 @@ > - + diff --git a/packages/ncform-theme-elementui/src/components/layout-comps/array-table.vue b/packages/ncform-theme-elementui/src/components/layout-comps/array-table.vue index 2dd09b9..e23522f 100755 --- a/packages/ncform-theme-elementui/src/components/layout-comps/array-table.vue +++ b/packages/ncform-theme-elementui/src/components/layout-comps/array-table.vue @@ -37,7 +37,7 @@
- +
@@ -50,7 +50,7 @@
- +
@@ -127,12 +127,16 @@ en: { action: 'Action', add: 'Add', - delAll: 'Delete All' + delAll: 'Delete All', + delItemTips: 'Are you sure to delete this item?', + delAllTips: 'Are you sure to delete all?' }, zh_cn: { action: '操作', add: '增加', - delAll: '删除全部' + delAll: '删除全部', + delItemTips: '确定要删除该项吗?', + delAllTips: '确定要删除全部吗?' } }, diff --git a/packages/ncform-theme-elementui/src/components/layout-comps/array-tabs.vue b/packages/ncform-theme-elementui/src/components/layout-comps/array-tabs.vue index 81b85fc..eb8f9d4 100755 --- a/packages/ncform-theme-elementui/src/components/layout-comps/array-tabs.vue +++ b/packages/ncform-theme-elementui/src/components/layout-comps/array-tabs.vue @@ -93,6 +93,15 @@ mixins: [layoutArrayMixin], + i18nData: { + en: { + delItemTips: 'Are you sure to delete this item?', + }, + zh_cn: { + delItemTips: '确定要删除该项吗?', + } + }, + data() { return { defaultConfig: { @@ -107,7 +116,7 @@ this.addItem(); } if (action === 'remove') { - this.delItem(targetName); + this.delItem(targetName, this.mergeConfig.requiredDelConfirm, this.mergeConfig.delConfirmText.item || this.$nclang('delItemTips')); } } } diff --git a/packages/ncform-theme-elementui/src/components/layout-comps/array.vue b/packages/ncform-theme-elementui/src/components/layout-comps/array.vue index b05f445..5a774bc 100755 --- a/packages/ncform-theme-elementui/src/components/layout-comps/array.vue +++ b/packages/ncform-theme-elementui/src/components/layout-comps/array.vue @@ -16,7 +16,7 @@
- +
@@ -45,7 +45,7 @@
- +
@@ -101,11 +101,15 @@ i18nData: { en: { add: 'Add', - delAll: 'Delete All' + delAll: 'Delete All', + delItemTips: 'Are you sure to delete this item?', + delAllTips: 'Are you sure to delete all?' }, zh_cn: { add: '增加', - delAll: '删除全部' + delAll: '删除全部', + delItemTips: '确定要删除该项吗?', + delAllTips: '确定要删除全部吗?' } }, diff --git a/packages/ncform-theme-elementui/src/components/layout-comps/object.vue b/packages/ncform-theme-elementui/src/components/layout-comps/object.vue index 2a3598b..f02e2a4 100755 --- a/packages/ncform-theme-elementui/src/components/layout-comps/object.vue +++ b/packages/ncform-theme-elementui/src/components/layout-comps/object.vue @@ -159,7 +159,7 @@ export default { }, methods: { legendEnable(fieldSchema) { - return fieldSchema.ui.showLegend && fieldSchema.ui.legend; + return fieldSchema.ui && fieldSchema.ui.showLegend && fieldSchema.ui.legend; } }, mixins: [layoutObjectMixin] diff --git a/packages/ncform/examples/components/vue-ncform/_layout-widgets.html b/packages/ncform/examples/components/vue-ncform/_layout-widgets.html index cf36fb43..e37fb65 100644 --- a/packages/ncform/examples/components/vue-ncform/_layout-widgets.html +++ b/packages/ncform/examples/components/vue-ncform/_layout-widgets.html @@ -152,6 +152,37 @@ } } }, + { + id: md5('array: deletion requires confirmation'), + title: 'array: deletion requires confirmation', + formName: 'form_' + Math.random(), + formSchema: { + type: 'object', + properties: { + users: { + type: 'array', + items: { + type: 'string' + }, + ui: { + widget: 'array', + widgetConfig: { + requiredDelConfirm: true, + delConfirmText: { + item: 'Sure to delete this item?', + all: 'Sure to delete all items?' + }, + } + } + } + }, + value: { + users: [ + 'daniel', 'sarah' + ] + } + } + }, { id: md5('array: collapsed / itemCollapse true and txts change'), title: 'array: collapsed / itemCollapse true and txts change', @@ -229,7 +260,34 @@ } } } - } + }, + { + id: md5('table: deletion requires confirmation'), + title: 'table: deletion requires confirmation', + formName: 'form_' + Math.random(), + formSchema: { + type: 'object', + properties: { + users: { + type: 'array', + items: { + type: 'string' + }, + ui: { + widget: 'array-table', + widgetConfig: { + requiredDelConfirm: true, + } + } + } + }, + value: { + users: [ + 'daniel', 'sarah' + ] + } + } + }, ] } }); diff --git a/packages/ncform/src/components/vue-ncform/index.js b/packages/ncform/src/components/vue-ncform/index.js index c2861b5..8043ff3 100755 --- a/packages/ncform/src/components/vue-ncform/index.js +++ b/packages/ncform/src/components/vue-ncform/index.js @@ -22,6 +22,8 @@ module.exports = { install: (Vue, options = { extComponents: {}, extRules: [], lang: '' }) => { window.__$ncform = {}; // 属于ncform的全局变量 + window.__$ncform.__ncformComponents = {}; + window.__$ncform.__ncFormsGlobalList = {}; window.__$ncform.__ncformRegularValidation = new RegularValidation(); @@ -31,7 +33,7 @@ module.exports = { // 注册组件 _map( Object.assign(defLayouts, defControls, options.extComponents || {}), - (compItem, name) => Vue.component(`ncform-${_kebabCase(name)}`, compItem) + (compItem, name) => { window.__$ncform.__ncformComponents[_kebabCase(name)] = 1; Vue.component(`ncform-${_kebabCase(name)}`, compItem) } ); // 注册验证规则 @@ -62,6 +64,7 @@ module.exports = { }; Vue.prototype.$ncformAddWidget = function({name, widget}) { + window.__$ncform.__ncformComponents[_kebabCase(name)] = 1; Vue.component(`ncform-${_kebabCase(name)}`, widget) } @@ -71,6 +74,14 @@ module.exports = { window.__$ncform.__ncformRegularValidation.registerRule(ruleItem); } + Vue.prototype.$ncformAllRules = function() { + return Object.keys(window.__$ncform.__ncformRegularValidation.allRules); + } + + Vue.prototype.$ncformAllWidgets = function() { + return Object.keys(window.__$ncform.__ncformComponents); + } + Vue.component("ncform", ncform); } }; diff --git a/packages/ncform/src/components/vue-ncform/layout-comps/array-table.vue b/packages/ncform/src/components/vue-ncform/layout-comps/array-table.vue index c132695..82d2b8c 100755 --- a/packages/ncform/src/components/vue-ncform/layout-comps/array-table.vue +++ b/packages/ncform/src/components/vue-ncform/layout-comps/array-table.vue @@ -32,7 +32,7 @@
- +
@@ -45,7 +45,7 @@
- +
@@ -83,12 +83,16 @@ en: { action: 'Action', add: 'Add', - delAll: 'Delete All' + delAll: 'Delete All', + delItemTips: 'Are you sure to delete this item?', + delAllTips: 'Are you sure to delete all?' }, zh_cn: { action: '操作', add: '增加', - delAll: '删除全部' + delAll: '删除全部', + delItemTips: '确定要删除该项吗?', + delAllTips: '确定要删除全部吗?' } }, diff --git a/packages/ncform/src/components/vue-ncform/layout-comps/array.vue b/packages/ncform/src/components/vue-ncform/layout-comps/array.vue index 581c497..5abb098 100755 --- a/packages/ncform/src/components/vue-ncform/layout-comps/array.vue +++ b/packages/ncform/src/components/vue-ncform/layout-comps/array.vue @@ -12,7 +12,7 @@
- +
@@ -41,7 +41,7 @@
- +
@@ -71,11 +71,15 @@ i18nData: { en: { add: 'Add', - delAll: 'Delete All' + delAll: 'Delete All', + delItemTips: 'Are you sure to delete this item?', + delAllTips: 'Are you sure to delete all?' }, zh_cn: { add: '增加', - delAll: '删除全部' + delAll: '删除全部', + delItemTips: '确定要删除该项吗?', + delAllTips: '确定要删除全部吗?' } }, diff --git a/packages/ncform/src/components/vue-ncform/layout-comps/object.vue b/packages/ncform/src/components/vue-ncform/layout-comps/object.vue index 939e61b..604792c 100755 --- a/packages/ncform/src/components/vue-ncform/layout-comps/object.vue +++ b/packages/ncform/src/components/vue-ncform/layout-comps/object.vue @@ -109,7 +109,7 @@ }, methods: { legendEnable(fieldSchema) { - return fieldSchema.ui.showLegend && fieldSchema.ui.legend; + return fieldSchema.ui && fieldSchema.ui.showLegend && fieldSchema.ui.legend; } }, mixins: [layoutObjectMixin]