@formio/js 5.0.0-dev.5632.8d1873d → 5.0.0-dev.5634.29c714c

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.
@@ -787,7 +787,8 @@ class Webform extends NestedDataComponent_1.default {
787
787
  formio.loadSubmissions({
788
788
  params: {
789
789
  state: 'draft',
790
- owner: userId
790
+ owner: userId,
791
+ sort: '-created'
791
792
  }
792
793
  }).then(submissions => {
793
794
  if (submissions.length > 0 && !this.options.skipDraftRestore) {
@@ -986,8 +986,14 @@ class WebformBuilder extends Component_1.default {
986
986
  else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
987
987
  parent.formioComponent.removeChildComponent(component);
988
988
  }
989
- if (component.input && componentInstance && componentInstance.parent) {
990
- lodash_1.default.unset(componentInstance._data, componentInstance.key);
989
+ if (component.input && componentInstance && parent.formioComponent) {
990
+ const parentDefaultValue = lodash_1.default.get(parent.formioComponent, 'component.defaultValue', null);
991
+ if (Array.isArray(parentDefaultValue)) {
992
+ parentDefaultValue.forEach(v => lodash_1.default.unset(v, componentInstance.key));
993
+ }
994
+ else if (typeof parentDefaultValue === 'object') {
995
+ lodash_1.default.unset(parentDefaultValue, componentInstance.key);
996
+ }
991
997
  }
992
998
  const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
993
999
  rebuild.then(() => {
@@ -630,9 +630,10 @@ class FormComponent extends Component_1.default {
630
630
  && submission._id
631
631
  && this.subForm.formio
632
632
  && lodash_1.default.isEmpty(submission.data);
633
- if (shouldLoadSubmissionById) {
633
+ const shouldLoadDraftById = this.options.saveDraft && lodash_1.default.isEmpty(submission.data) && lodash_1.default.get(this.subForm, 'submission._id');
634
+ if (shouldLoadSubmissionById || shouldLoadDraftById) {
634
635
  const formId = submission.form || this.formObj.form || this.component.form;
635
- const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
636
+ const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
636
637
  const options = ((_a = this.root.formio) === null || _a === void 0 ? void 0 : _a.base) && ((_b = this.root.formio) === null || _b === void 0 ? void 0 : _b.projectUrl)
637
638
  ? {
638
639
  base: this.root.formio.base,
@@ -791,7 +791,8 @@ export default class Webform extends NestedDataComponent {
791
791
  formio.loadSubmissions({
792
792
  params: {
793
793
  state: 'draft',
794
- owner: userId
794
+ owner: userId,
795
+ sort: '-created'
795
796
  }
796
797
  }).then(submissions => {
797
798
  if (submissions.length > 0 && !this.options.skipDraftRestore) {
@@ -970,8 +970,14 @@ export default class WebformBuilder extends Component {
970
970
  else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
971
971
  parent.formioComponent.removeChildComponent(component);
972
972
  }
973
- if (component.input && componentInstance && componentInstance.parent) {
974
- _.unset(componentInstance._data, componentInstance.key);
973
+ if (component.input && componentInstance && parent.formioComponent) {
974
+ const parentDefaultValue = _.get(parent.formioComponent, 'component.defaultValue', null);
975
+ if (Array.isArray(parentDefaultValue)) {
976
+ parentDefaultValue.forEach(v => _.unset(v, componentInstance.key));
977
+ }
978
+ else if (typeof parentDefaultValue === 'object') {
979
+ _.unset(parentDefaultValue, componentInstance.key);
980
+ }
975
981
  }
976
982
  const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
977
983
  rebuild.then(() => {
@@ -620,9 +620,10 @@ export default class FormComponent extends Component {
620
620
  && submission._id
621
621
  && this.subForm.formio
622
622
  && _.isEmpty(submission.data);
623
- if (shouldLoadSubmissionById) {
623
+ const shouldLoadDraftById = this.options.saveDraft && _.isEmpty(submission.data) && _.get(this.subForm, 'submission._id');
624
+ if (shouldLoadSubmissionById || shouldLoadDraftById) {
624
625
  const formId = submission.form || this.formObj.form || this.component.form;
625
- const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
626
+ const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
626
627
  const options = this.root.formio?.base && this.root.formio?.projectUrl
627
628
  ? {
628
629
  base: this.root.formio.base,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5632.8d1873d",
3
+ "version": "5.0.0-dev.5634.29c714c",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {