From 3355fe8bd9dff9c6f83c54c3440b2056c0dd06bf Mon Sep 17 00:00:00 2001 From: kushthedude Date: Fri, 29 Nov 2019 12:19:23 +0530 Subject: [PATCH 1/5] Removing date and time validations --- .../forms/events/view/create-discount-code.js | 46 ------------------- .../forms/wizard/basic-details-step.js | 21 --------- .../forms/wizard/sessions-speakers-step.js | 22 --------- 3 files changed, 89 deletions(-) diff --git a/app/components/forms/events/view/create-discount-code.js b/app/components/forms/events/view/create-discount-code.js index 0f2fdd3bb45..642d55a4141 100644 --- a/app/components/forms/events/view/create-discount-code.js +++ b/app/components/forms/events/view/create-discount-code.js @@ -3,7 +3,6 @@ import { computed } from '@ember/object'; import FormMixin from 'open-event-frontend/mixins/form'; import { later } from '@ember/runloop'; import { currencySymbol } from 'open-event-frontend/helpers/currency-symbol'; -import moment from 'moment'; export default Component.extend(FormMixin, { getValidationRules() { window.$.fn.form.settings.rules.checkMaxMin = () => { @@ -22,11 +21,6 @@ export default Component.extend(FormMixin, { return false; }; - window.$.fn.form.settings.rules.checkDates = () => { - let startDatetime = moment(this.get('data.validFrom')); - let endDatetime = moment(this.get('data.validTill')); - return (endDatetime.diff(startDatetime, 'minutes') > 0); - }; return { inline : true, delay : false, @@ -113,46 +107,6 @@ export default Component.extend(FormMixin, { prompt : this.l10n.t('Please select atleast 1 ticket.') } ] - }, - startDate: { - optional : true, - identifier : 'start_date', - rules : [ - { - type : 'checkDates', - prompt : this.l10n.t('Valid Till date & time should be after valid from date and time') - } - ] - }, - startTime: { - optional : true, - identifier : 'start_time', - rules : [ - { - type : 'checkDates', - prompt : '.' - } - ] - }, - endDate: { - optional : true, - identifier : 'end_date', - rules : [ - { - type : 'checkDates', - prompt : this.l10n.t('Valid Till date & time should be after valid from date and time') - } - ] - }, - endTime: { - optional : true, - identifier : 'end_time', - rules : [ - { - type : 'checkDates', - prompt : '.' - } - ] } } }; diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index e072c97e98a..dfce1de0797 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -126,11 +126,6 @@ export default Component.extend(FormMixin, EventWizardMixin, { }, getValidationRules() { - window.$.fn.form.settings.rules.checkDates = () => { - let startDatetime = moment(this.get('data.event.startsAt')); - let endDatetime = moment(this.get('data.event.endsAt')); - return (endDatetime.diff(startDatetime, 'minutes') > 0); - }; let validationRules = { inline : true, @@ -165,10 +160,6 @@ export default Component.extend(FormMixin, EventWizardMixin, { { type : 'date', prompt : this.l10n.t('Please give a valid start date') - }, - { - type : 'checkDates', - prompt : this.l10n.t('Start date & time should be before End date and time') } ] }, @@ -182,10 +173,6 @@ export default Component.extend(FormMixin, EventWizardMixin, { { type : 'date', prompt : this.l10n.t('Please give a valid end date') - }, - { - type : 'checkDates', - prompt : this.l10n.t('Start date & time should be before End date and time') } ] }, @@ -196,10 +183,6 @@ export default Component.extend(FormMixin, EventWizardMixin, { { type : 'empty', prompt : this.l10n.t('Please give a start time') - }, - { - type : 'checkDates', - prompt : '..' } ] }, @@ -210,10 +193,6 @@ export default Component.extend(FormMixin, EventWizardMixin, { { type : 'empty', prompt : this.l10n.t('Please give an end time') - }, - { - type : 'checkDates', - prompt : '..' } ] }, diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index a1ba6e59dca..957b5f3fb2d 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -3,16 +3,10 @@ import { computed } from '@ember/object'; import FormMixin from 'open-event-frontend/mixins/form'; import EventWizardMixin from 'open-event-frontend/mixins/event-wizard'; import { groupBy } from 'lodash-es'; -import moment from 'moment'; export default Component.extend(EventWizardMixin, FormMixin, { getValidationRules() { - window.$.fn.form.settings.rules.checkDates = () => { - let startDatetime = moment(this.get('data.speakersCall.startsAt')); - let endDatetime = moment(this.get('data.speakersCall.endsAt')); - return (endDatetime.diff(startDatetime, 'minutes') > 0); - }; return { inline : true, delay : false, @@ -60,10 +54,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { { type : 'empty', prompt : this.l10n.t('Please tell us when your event starts') - }, - { - type : 'checkDates', - prompt : this.l10n.t('Start date & time ') } ] }, @@ -73,10 +63,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { { type : 'empty', prompt : this.l10n.t('Please tell us when your event ends') - }, - { - type : 'checkDates', - prompt : this.l10n.t('Start date & time should be after End date and time') } ] }, @@ -87,10 +73,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { { type : 'empty', prompt : this.l10n.t('Please give a start time') - }, - { - type : 'checkDates', - prompt : '.' } ] }, @@ -101,10 +83,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { { type : 'empty', prompt : this.l10n.t('Please give an end time') - }, - { - type : 'checkDates', - prompt : '.' } ] } From d8ff7ad61e9a85159b5da77af0a3651c5de97889 Mon Sep 17 00:00:00 2001 From: kushthedude Date: Sat, 30 Nov 2019 02:23:19 +0530 Subject: [PATCH 2/5] Adding comment for future reference --- app/components/forms/events/view/create-discount-code.js | 2 +- app/components/forms/wizard/basic-details-step.js | 2 +- app/components/forms/wizard/sessions-speakers-step.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/forms/events/view/create-discount-code.js b/app/components/forms/events/view/create-discount-code.js index 642d55a4141..74d9c9ab0f0 100644 --- a/app/components/forms/events/view/create-discount-code.js +++ b/app/components/forms/events/view/create-discount-code.js @@ -20,7 +20,7 @@ export default Component.extend(FormMixin, { } return false; }; - +// Removing the Discount Code Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 return { inline : true, delay : false, diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index dfce1de0797..36763d359d9 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -124,7 +124,7 @@ export default Component.extend(FormMixin, EventWizardMixin, { this.set('data.event.copyright', this.store.createRecord('event-copyright')); } }, - +// Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { let validationRules = { diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index 957b5f3fb2d..0c87647a413 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -5,7 +5,7 @@ import EventWizardMixin from 'open-event-frontend/mixins/event-wizard'; import { groupBy } from 'lodash-es'; export default Component.extend(EventWizardMixin, FormMixin, { - +// Removing the Session & Speaker Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { return { inline : true, From 1777718ea827d025c1e075ee46bedd05963f8ca8 Mon Sep 17 00:00:00 2001 From: kushthedude Date: Sat, 30 Nov 2019 02:25:26 +0530 Subject: [PATCH 3/5] Spacing fixes --- app/components/forms/events/view/create-discount-code.js | 8 +++++++- app/components/forms/wizard/basic-details-step.js | 3 ++- app/components/forms/wizard/sessions-speakers-step.js | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/components/forms/events/view/create-discount-code.js b/app/components/forms/events/view/create-discount-code.js index 74d9c9ab0f0..40df33425a0 100644 --- a/app/components/forms/events/view/create-discount-code.js +++ b/app/components/forms/events/view/create-discount-code.js @@ -8,9 +8,11 @@ export default Component.extend(FormMixin, { window.$.fn.form.settings.rules.checkMaxMin = () => { return this.get('data.minQuantity') <= this.get('data.maxQuantity'); }; + window.$.fn.form.settings.rules.checkMaxTotal = () => { return this.get('data.maxQuantity') <= this.get('data.ticketsNumber'); }; + window.$.fn.form.settings.rules.checkTicketSelected = () => { let tickets = this.eventTickets; for (let ticket of tickets) { @@ -18,9 +20,11 @@ export default Component.extend(FormMixin, { return true; } } + return false; }; -// Removing the Discount Code Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + + // Removing the Discount Code Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 return { inline : true, delay : false, @@ -129,6 +133,7 @@ export default Component.extend(FormMixin, { if (this.eventTickets.length && this.get('data.tickets').length === this.eventTickets.length) { return true; } + return false; }), @@ -143,6 +148,7 @@ export default Component.extend(FormMixin, { } else { this.get('data.tickets').clear(); } + tickets.forEach(ticket => { ticket.set('isChecked', allTicketTypesChecked); }); diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index 36763d359d9..0ad2fa3bb63 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -124,7 +124,8 @@ export default Component.extend(FormMixin, EventWizardMixin, { this.set('data.event.copyright', this.store.createRecord('event-copyright')); } }, -// Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + + // Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { let validationRules = { diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index 0c87647a413..13a2fb5d6c3 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -5,7 +5,8 @@ import EventWizardMixin from 'open-event-frontend/mixins/event-wizard'; import { groupBy } from 'lodash-es'; export default Component.extend(EventWizardMixin, FormMixin, { -// Removing the Session & Speaker Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + + // Removing the Session & Speaker Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { return { inline : true, @@ -114,6 +115,7 @@ export default Component.extend(EventWizardMixin, FormMixin, { if (!field.get('isIncluded')) { field.set('isRequired', false); } + if (field.get('isRequired')) { field.set('isIncluded', true); } From 1feff9af5557c0e0cb018eefd2b00c13d2ec892b Mon Sep 17 00:00:00 2001 From: kushthedude Date: Sat, 30 Nov 2019 02:27:57 +0530 Subject: [PATCH 4/5] Spacing fixes --- app/components/forms/events/view/create-discount-code.js | 5 ----- app/components/forms/wizard/sessions-speakers-step.js | 1 - 2 files changed, 6 deletions(-) diff --git a/app/components/forms/events/view/create-discount-code.js b/app/components/forms/events/view/create-discount-code.js index 40df33425a0..f49a23ba8f3 100644 --- a/app/components/forms/events/view/create-discount-code.js +++ b/app/components/forms/events/view/create-discount-code.js @@ -8,11 +8,9 @@ export default Component.extend(FormMixin, { window.$.fn.form.settings.rules.checkMaxMin = () => { return this.get('data.minQuantity') <= this.get('data.maxQuantity'); }; - window.$.fn.form.settings.rules.checkMaxTotal = () => { return this.get('data.maxQuantity') <= this.get('data.ticketsNumber'); }; - window.$.fn.form.settings.rules.checkTicketSelected = () => { let tickets = this.eventTickets; for (let ticket of tickets) { @@ -20,7 +18,6 @@ export default Component.extend(FormMixin, { return true; } } - return false; }; @@ -133,7 +130,6 @@ export default Component.extend(FormMixin, { if (this.eventTickets.length && this.get('data.tickets').length === this.eventTickets.length) { return true; } - return false; }), @@ -148,7 +144,6 @@ export default Component.extend(FormMixin, { } else { this.get('data.tickets').clear(); } - tickets.forEach(ticket => { ticket.set('isChecked', allTicketTypesChecked); }); diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index 13a2fb5d6c3..1edf5b596db 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -115,7 +115,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { if (!field.get('isIncluded')) { field.set('isRequired', false); } - if (field.get('isRequired')) { field.set('isIncluded', true); } From ac2ae89875720f83c1feb73959c3aad0f82b1c5f Mon Sep 17 00:00:00 2001 From: kushthedude Date: Sat, 30 Nov 2019 02:39:38 +0530 Subject: [PATCH 5/5] updating comment --- app/components/forms/events/view/create-discount-code.js | 2 +- app/components/forms/wizard/basic-details-step.js | 2 +- app/components/forms/wizard/sessions-speakers-step.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/forms/events/view/create-discount-code.js b/app/components/forms/events/view/create-discount-code.js index f49a23ba8f3..8f7874b9f33 100644 --- a/app/components/forms/events/view/create-discount-code.js +++ b/app/components/forms/events/view/create-discount-code.js @@ -21,7 +21,7 @@ export default Component.extend(FormMixin, { return false; }; - // Removing the Discount Code Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + // TODO: Removing the Discount Code Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 return { inline : true, delay : false, diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index 0ad2fa3bb63..e25ba000bdd 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -125,7 +125,7 @@ export default Component.extend(FormMixin, EventWizardMixin, { } }, - // Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + // TODO: Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { let validationRules = { diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index 1edf5b596db..0c96bbe432f 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -6,7 +6,7 @@ import { groupBy } from 'lodash-es'; export default Component.extend(EventWizardMixin, FormMixin, { - // Removing the Session & Speaker Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 + // TODO: Removing the Session & Speaker Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667 getValidationRules() { return { inline : true,