Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/components/forms/admin/settings/system-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ export default Component.extend(FormMixin, {
]
},

orderExpiryTime: {
identifier : 'order_expiry_time',
rules : [
{
type : 'empty',
prompt : this.l10n.t('Please enter a Expiry Time for Order')
}]
},

googlereCAPTCHAsecretkey: {
identifier : 'google_recaptcha_secretkey',
rules : [
Expand Down
1 change: 1 addition & 0 deletions app/components/forms/admin/settings/system/captcha-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Component from '@ember/component';

export default Component.extend({

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Component from '@ember/component';

export default Component.extend({
});
18 changes: 0 additions & 18 deletions app/components/forms/events/view/order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@ import Component from '@ember/component';
import FormMixin from 'open-event-frontend/mixins/form';

export default Component.extend(FormMixin, {
getValidationRules() {
return {
inline : true,
delay : false,
on : 'blur',
fields : {
orderExpiryTime: {
identifier : 'orderExpiryTime',
rules : [
{
type : 'integer[1..60]',
prompt : this.l10n.t('Please enter a valid registration time limit between 1 to 60 minutes.')
}
]
}
}
};
},
actions: {
submit(data) {
this.onValid(() => {
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/orders/order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default Component.extend(FormMixin, {
}),
sameAsBuyer: false,

getRemainingTime: computed('data', function() {
let orderExpiryTime = this.get('data.event.orderExpiryTime');
getRemainingTime: computed('settings', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The computed property should be observing everything you are using. settings.orderExpiryTime, data.createdAt and data.identifier.

Please pay more attention to detail

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what is this computer property returning ? I see no return statement at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niranjan94 , Same but it was implemented earlier this way, It's just used to calculate remaining time and this calls timer in it to calculate, But still no return it has

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niranjan94 I tried to return getRemaining but alas it was of no use due to the re-rendering of a rendered value, That's why I think this.set is used to overcome this challenge

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very incorrect usage of a computed property. And a computed property should also never be reset by something else. Please refactor this correctly.

let orderExpiryTime = this.get('settings.orderExpiryTime');
let willExpireAt = this.get('data.createdAt').add(orderExpiryTime, 'minutes');
this.timer(willExpireAt, this.get('data.identifier'));
}),
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default Controller.extend({
settings.save()
.then(() => {
this.notify.success(this.l10n.t('Settings have been saved successfully.'));
this.send('refreshRoute');
})
.catch(() => {
this.notify.error(this.l10n.t('An unexpected error has occurred. Settings not saved.'));
Expand Down
1 change: 0 additions & 1 deletion app/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default ModelBase.extend(CustomPrimaryKeyMixin, {
chequeDetails : attr('string'),
bankDetails : attr('string'),
onsiteDetails : attr('string'),
orderExpiryTime : attr('number', { defaultValue: 10 }),

schedulePublishedOn: attr('moment', { defaultValue: () => moment(0) }),

Expand Down
1 change: 1 addition & 0 deletions app/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default ModelBase.extend({
appEnvironment : attr('string'),
appName : attr('string'),
tagline : attr('string'),
orderExpiryTime : attr('number', { defaultValue: 15 }),
secret : attr('string'),
storagePlace : attr('string'),
awsKey : attr('string'),
Expand Down
3 changes: 3 additions & 0 deletions app/routes/admin/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default Route.extend({
actions: {
willTransition() {
this.get('controller.model').rollbackAttributes();
},
refreshRoute() {
this.refresh();
}
}
});
2 changes: 2 additions & 0 deletions app/templates/components/forms/admin/settings/system-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<div class="ui hidden divider"></div>
{{forms/admin/settings/system/mail-settings settings=settings}}
<div class="ui hidden divider"></div>
{{forms/admin/settings/system/order-expiry-form settings=settings}}
<div class="ui hidden divider"></div>
<h3 class="ui header">
{{t 'App secret key'}}
<div class="sub header">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h3 class="ui header">
{{t 'Order Expiry Time'}}
<div class="sub header">
{{t 'Set registration time limit for your order'}}
</div>
</h3>
<div class="field">
<label class="required">{{t 'REGISTRATION TIME LIMIT'}}</label>
<div class="{{unless device.isMobile 'two wide'}} field">
{{input type='number' id='orderExpiryTime' name='order_expiry_time' value=settings.orderExpiryTime min="1" max="60" step="1"}}
</div>
</div>
12 changes: 0 additions & 12 deletions app/templates/components/forms/events/view/order-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@
</table>
</div>
</div>
<h3 class="ui dividing header">
<i class="options box icon"></i>
<div class="content">
{{t 'Registration Options'}}
</div>
</h3>
<div class="field">
<label>{{t 'REGISTRATION TIME LIMIT'}}</label>
<div class="{{unless device.isMobile 'two wide'}} field">
{{input type='number' id='orderExpiryTime' value=data.event.orderExpiryTime min="1" max="60" step="1"}}
</div>
</div>
<div class="ui hidden divider"></div>
<button type="submit" class="ui teal submit button" name="submit">{{t 'Save'}}</button>
</form>
4 changes: 2 additions & 2 deletions app/templates/components/forms/orders/order-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{{getRemainingTime}}
</div>
<div class="label">
{{t 'Please complete registration within '}} {{data.event.orderExpiryTime}} {{t 'minutes.'}}
{{t 'Please complete registration within '}} {{settings.orderExpiryTime}} {{t 'minutes.'}}
<br>
{{t 'After '}} {{data.event.orderExpiryTime}} {{t 'minutes, the reservation we\'re holding will be released to others.'}}
{{t 'After '}} {{settings.orderExpiryTime}} {{t 'minutes, the reservation we\'re holding will be released to others.'}}
</div>
</div>
</div>
Expand Down
12 changes: 0 additions & 12 deletions app/templates/components/forms/wizard/attendee-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@
</table>
</div>
</div>
<h3 class="ui dividing header">
<i class="options box icon"></i>
<div class="content">
{{t 'Registration Options'}}
</div>
</h3>
<div class="field">
<label>{{t 'REGISTRATION TIME LIMIT'}}</label>
<div class="{{unless device.isMobile 'two wide'}} field">
{{input type='number' id='orderExpiryTime' value=data.event.orderExpiryTime min="1" max="60" step="1"}}
</div>
</div>
{{/if}}
<div class="spacer-50"></div>
<div class="{{if device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/orders/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
<div class="row">
<div class="ten wide column">
{{forms/orders/order-form save='save' data=model.order fields=model.form}}
{{forms/orders/order-form save='save' data=model.order fields=model.form settings=settings}}
</div>
<div class="six wide column">
{{#if model.order.event.organizerName}}
Expand Down