Skip to content

Commit ad13bb4

Browse files
Merge branch 'fixes'
2 parents 69a42cf + 6e048d0 commit ad13bb4

24 files changed

+266
-233
lines changed

dist/formio.contrib.js

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.contrib.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.embed.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.embed.min.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.form.js

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.form.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.full.js

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.full.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formio.utils.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/components/datagrid/DataGrid.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function (_NestedComponent) {
173173
value: function hasAddButton() {
174174
var maxLength = _lodash.default.get(this.component, 'validate.maxLength');
175175

176-
return !this.component.disableAddingRemovingRows && !this.shouldDisable && !this.options.builder && !this.options.preview && (!maxLength || this.dataValue.length < maxLength);
176+
return !this.component.disableAddingRemovingRows && !this.component.disableAddingRows && !this.shouldDisable && !this.options.builder && !this.options.preview && (!maxLength || this.dataValue.length < maxLength);
177177
}
178178
}, {
179179
key: "hasExtraColumn",
@@ -340,6 +340,13 @@ function (_NestedComponent) {
340340
}, hasTopButton ? this.addButton(true) : null) : null]));
341341
return needsHeader ? thead : null;
342342
}
343+
}, {
344+
key: "restoreValue",
345+
value: function restoreValue() {
346+
if (this.hasAddButton()) {
347+
_get(_getPrototypeOf(DataGridComponent.prototype), "restoreValue", this).call(this);
348+
}
349+
}
343350
}, {
344351
key: "buildRow",
345352
value: function buildRow(rowData, index, state) {
@@ -799,7 +806,7 @@ function (_NestedComponent) {
799806
}, {
800807
key: "emptyValue",
801808
get: function get() {
802-
return [{}];
809+
return this.hasAddButton() ? [{}] : [];
803810
}
804811
}, {
805812
key: "addAnotherPosition",

lib/components/datagrid/editForm/DataGrid.edit.display.js

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ var _default = [{
1414
clearOnHide: false,
1515
customConditional: 'show = !data.enableRowGroups',
1616
calculateValue: 'value = data.enableRowGroups ? true : data.disableAddingRemovingRows;'
17+
}, {
18+
type: 'checkbox',
19+
label: 'Disable Adding Rows',
20+
key: 'disableAddingRows',
21+
tooltip: 'Check if you want to hide Add Another button',
22+
weight: 406,
23+
input: true,
24+
clearOnHide: false,
25+
customConditional: 'show = !data.disableAddingRemovingRows'
1726
}, {
1827
type: 'textfield',
1928
label: 'Add Another Text',

lib/dist/formio.contrib.js

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.contrib.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.embed.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.embed.min.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.form.js

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.form.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.full.js

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.full.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dist/formio.utils.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/datagrid/DataGrid.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class DataGridComponent extends NestedComponent {
4848
}
4949

5050
get emptyValue() {
51-
return [{}];
51+
return (this.hasAddButton()) ? [{}] : [];
5252
}
5353

5454
get addAnotherPosition() {
@@ -62,6 +62,7 @@ export default class DataGridComponent extends NestedComponent {
6262
hasAddButton() {
6363
const maxLength = _.get(this.component, 'validate.maxLength');
6464
return !this.component.disableAddingRemovingRows &&
65+
!this.component.disableAddingRows &&
6566
!this.shouldDisable &&
6667
!this.options.builder &&
6768
!this.options.preview &&
@@ -240,6 +241,12 @@ export default class DataGridComponent extends NestedComponent {
240241
return this.emptyValue;
241242
}
242243

244+
restoreValue() {
245+
if (this.hasAddButton()) {
246+
super.restoreValue();
247+
}
248+
}
249+
243250
buildRow(rowData, index, state) {
244251
state = state || {};
245252
const components = _.get(this, 'component.components', []);

src/components/datagrid/editForm/DataGrid.edit.display.js

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ export default [
1010
customConditional: 'show = !data.enableRowGroups',
1111
calculateValue: 'value = data.enableRowGroups ? true : data.disableAddingRemovingRows;',
1212
},
13+
{
14+
type: 'checkbox',
15+
label: 'Disable Adding Rows',
16+
key: 'disableAddingRows',
17+
tooltip: 'Check if you want to hide Add Another button',
18+
weight: 406,
19+
input: true,
20+
clearOnHide: false,
21+
customConditional: 'show = !data.disableAddingRemovingRows'
22+
},
1323
{
1424
type: 'textfield',
1525
label: 'Add Another Text',

0 commit comments

Comments
 (0)