Skip to content

Commit 251b809

Browse files
khangoncweitat
andauthored
Feature-8881: Unable to re-add language after deleting (#8904)
* feature-8881: Unable to re-add language after deleting * fix-8881 unable to save after remove translation field * fix-8881 fix issue not able to delete custom field while editing * format code * fix-8881 * fix-8881 fix speaker unable to add custom field --------- Co-authored-by: cweitat <[email protected]>
1 parent 63e6b86 commit 251b809

File tree

8 files changed

+35
-4
lines changed

8 files changed

+35
-4
lines changed

app/components/forms/wizard/custom-form-input-translation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ export default class CustomFormInputTranslation extends Component<Args> {
3535
if (this.args.onRemoveTranslation) {
3636
this.args.onRemoveTranslation(this.args.data)
3737
}
38+
if (this.args.onChange) {
39+
this.args.onChange(this.args.data, '')
40+
}
3841
}
3942
}

app/components/forms/wizard/custom-form-input.hbs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262
<div>
6363
{{#if (eq @form 'attendee')}}
6464
<button class="ui button h-full" {{action 'addTranslation'}} disabled={{this.disableAddTranslation}}>{{t 'Add Translation'}}</button>
65+
<button class="ui button h-full" {{action @setEditingField}} {{action 'addFormField'}} disabled={{not this.validIdentifier}} >{{if @field (t 'Save') (t 'Add')}}</button>
66+
{{else}}
67+
<button class="ui button h-full" {{action 'addFormField'}} disabled={{not this.validIdentifier}} >{{if @field (t 'Save') (t 'Add')}}</button>
6568
{{/if}}
66-
<button class="ui button h-full" {{action 'addFormField'}} disabled={{not this.validIdentifier}}>{{if @field (t 'Save') (t 'Add')}}</button>
6769
</div>
6870
</div>
6971
</div>

app/components/forms/wizard/custom-form-input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default class CustomFormInput extends Component<Args> {
127127
return getIdentifier(this.name, this.args.customForms);
128128
}
129129

130-
@computed('name', 'selectedLanguage.@each', '[email protected]')
130+
@computed('name', 'selectedLanguage.@each', '[email protected]', '[email protected]')
131131
get validIdentifier(): boolean {
132132
const nameValid = this.identifier.trim().length > 0 && this.name.trim().length > 0;
133133
const transInValid = this.subForm.filter(field => !field.isDeleted && (!field.name || !field.selectedLang))
@@ -234,7 +234,9 @@ export default class CustomFormInput extends Component<Args> {
234234
if (old_code) {
235235
this.selectedLanguage.removeObject(old_code)
236236
}
237-
this.selectedLanguage.pushObject(new_code)
237+
if (new_code) {
238+
this.selectedLanguage.pushObject(new_code)
239+
}
238240
}
239241

240242
@computed('[email protected]')

app/components/forms/wizard/custom-form-ticket.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import EventWizardMixin from 'open-event-frontend/mixins/event-wizard';
55
import { sortBy, union } from 'lodash-es';
66

77
export default Component.extend(FormMixin, EventWizardMixin, {
8-
currentSelected: [],
8+
currentSelected : [],
9+
trackedfieldEditing : [],
910
init() {
1011
this._super(...arguments);
1112
this.currentSelected = this.data.ticketsDetails;
@@ -54,9 +55,16 @@ export default Component.extend(FormMixin, EventWizardMixin, {
5455
return this.editableFields?.some(field => field.isComplex);
5556
}),
5657

58+
getEditingField: computed('fieldEditing', function() {
59+
return this.fieldEditing;
60+
}),
61+
5762
actions: {
5863
removeField(field) {
5964
field.deleteRecord();
65+
},
66+
setEditingField(name) {
67+
this.set('fieldEditing', name);
6068
}
6169
}
6270
});

app/components/forms/wizard/custom-forms/table.hbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,23 @@
125125
{{#if this.complexColumn}}
126126
<td class="border center aligned">
127127
{{#if field.isComplex}}
128+
{{#if (eq @form 'attendee')}}
129+
<button class="ui compact icon positive circular button" data-tooltip="{{t 'Edit'}}" {{action @updateField field}} {{action @setEditingField field.name}}>
130+
<i class="pencil icon"></i>
131+
</button>
132+
<button class="ui compact icon negative circular button" disabled={{if (eq @getEditingField field.name) true false}} data-tooltip="{{t 'Delete'}}" {{action (confirm (t "Are you sure you want to delete this?") (action @removeField field))}}>
133+
<i class="trash icon"></i>
134+
</button>
135+
{{else}}
128136
<button class="ui compact icon positive circular button" data-tooltip="{{t 'Edit'}}" {{action @updateField field}}>
129137
<i class="pencil icon"></i>
130138
</button>
131139
<button class="ui compact icon negative circular button" data-tooltip="{{t 'Delete'}}" {{action (confirm (t "Are you sure you want to delete this?") (action @removeField field))}}>
132140
<i class="trash icon"></i>
133141
</button>
134142
{{/if}}
143+
144+
{{/if}}
135145
</td>
136146
{{/if}}
137147
</DraggableObject>

app/templates/components/forms/wizard/attendee-step.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
@event={{this.data.event}}
6262
@form="attendee"
6363
@field={{this.field}}
64+
@setEditingField={{action (mut this.field) null}}
6465
@onSave={{action (mut this.field) null}} />
6566
{{else}}
6667
<div class="ui hidden divider"></div>

app/templates/components/forms/wizard/custom-form-ticket.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
@fields={{this.editableFields}}
3737
@form={{"attendee"}}
3838
@removeField={{action "removeField"}}
39+
@setEditingField={{action "setEditingField"}}
40+
@getEditingField={{this.getEditingField}}
3941
@updateField={{action (mut this.ticketField)}}
4042
/>
4143
</div>
@@ -45,6 +47,7 @@
4547
@event={{this.event}}
4648
@form="attendee"
4749
@field={{this.ticketField}}
50+
@setEditingField={{action "setEditingField"}}
4851
@formIdentifier={{this.id}}
4952
@onSave={{action (mut this.ticketField) null}} />
5053
<div class="ui hidden divider"></div>

app/templates/components/forms/wizard/sessions-speakers-step.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
@headerText={{t "Collect Speaker Details"}}
242242
@fields={{this.customForm.speaker}}
243243
@updateField={{action (mut this.speakerField)}}
244+
@form="speaker"
244245
@removeField={{action "removeField"}}
245246
/>
246247

@@ -257,6 +258,7 @@
257258
@headerText={{t "Collect Session Details"}}
258259
@fields={{this.customForm.session}}
259260
@updateField={{action (mut this.sessionField)}}
261+
@form="session"
260262
@removeField={{action "removeField"}}
261263
/>
262264

0 commit comments

Comments
 (0)