Skip to content

Commit

Permalink
Updated code to call correct endpoint for key
Browse files Browse the repository at this point in the history
Also moved ID for current record out of Curval condition
  • Loading branch information
droberts-ctrlo committed Dec 27, 2024
1 parent a13063b commit 10f3ea0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import gadsStorage from "util/gadsStorage";

export default abstract class AutosaveBase extends Component {
constructor(element: HTMLElement) {
super(element);
this.initAutosave();
super(element);
this.initAutosave();
}

get isClone() {
Expand All @@ -16,8 +16,7 @@ export default abstract class AutosaveBase extends Component {
}

get recordId() {
const id = location.pathname.split('/').pop();
return isNaN(parseInt(id)) ? 0 : id;
return $('body').find('.form-edit').data('current-id') || 0;
}

get storage() {
Expand All @@ -28,7 +27,7 @@ export default abstract class AutosaveBase extends Component {
return `linkspace-record-change-${this.layoutId}-${this.recordId}`;
}

columnKey($field:JQuery) {
columnKey($field: JQuery) {
return `linkspace-column-${$field.data('column-id')}-${this.layoutId}-${this.recordId}`;
}

Expand Down
11 changes: 1 addition & 10 deletions src/frontend/components/modal/modals/curval/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
//import { getComponentElements, initializeComponent } from 'component'
import { initializeComponent } from 'component';
import CurvalModalComponent from './lib/component';

// Originally this was an async load - this has been changed as the autosave code becomes overcomplex with async
export default (scope) => initializeComponent(scope, '.modal--curval', CurvalModalComponent);

//export default (scope) => {
// if (!getComponentElements(scope, '.modal--curval').length) return;

// import(/* webpackChunkName="modal" */ "./lib/component")
// .then(({ default: CurvalModalComponent }) => {
// initializeComponent(scope, '.modal--curval', CurvalModalComponent)
// });
//}
2 changes: 1 addition & 1 deletion src/frontend/js/lib/util/gadsStorage/lib/gadsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GadsStorage {
}

private async getStorageKey() {
const fetchResult = await fetch("/get_key");
const fetchResult = await fetch("/api/get_key");
const data = await fetchResult.json();
if (data.error !== 0) {
throw new Error("Failed to get storage key");
Expand Down
2 changes: 1 addition & 1 deletion views/edit.tt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class="[% IF edit_modal %]curval-edit-form[% ELSE %]form-edit[% END %]"
method="post"
enctype="multipart/form-data"
data-current-id="[% cur_id %]"
[%
IF edit_modal;
action = cur_id
Expand All @@ -19,7 +20,6 @@
%]
action="[% action %]" [%# This form also used for bulk actions %]
data-curval-id="[% edit_modal %]"
data-current-id="[% cur_id %]"
data-modal-field-ids="[% modal_field_ids %]"
data-instance-name="[% layout.identifier %]"
[% END; %]
Expand Down

0 comments on commit 10f3ea0

Please sign in to comment.