Skip to content

fix: Discount Codes: Simplify Form #5758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions app/models/discount-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default ModelBase.extend({
code : attr('string'),
type : attr('string', { defaultValue: 'amount' }),
value : attr('number'),
ticketsNumber : attr('number'), // For form (1) this holds the max. times this can be used for events
ticketsNumber : attr('number', { defaultValue: 10 }), // For form (1) this holds the max. times this can be used for events
minQuantity : attr('number', { defaultValue: 0 }), // Not of any significance for form (1)
maxQuantity : attr('number'), // For form (1) this holds the number of months this code is valid for events
maxQuantity : attr('number', { defaultValue: 100000 }),
validFrom : attr('moment', { defaultValue: () => moment().startOf('day') }),
discountUrl : attr('string'),
validTill : attr('moment', { defaultValue: () => moment().add(1, 'months').startOf('day') }),
Expand Down
111 changes: 36 additions & 75 deletions app/templates/components/forms/events/view/create-discount-code.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@
@value={{this.data.ticketsNumber}}
@min="0" />
</div>
<div class="grouped inline fields">
<label class="required">{{t 'Status'}}</label>
<div class="field">
<UiRadio
@name="status"
@label={{t "Active"}}
@current={{this.data.isActive}}
@value={{true}}
@onChange={{action (mut this.data.isActive)}} />
</div>
<div class="field">
<UiRadio
@name="status"
@label={{t "Inactive"}}
@value={{false}}
@current={{this.data.isActive}}
@onChange={{action (mut this.data.isActive)}} />
</div>
</div>
{{#if this.eventTickets}}
<div class="inline field">
<label class="required">{{t 'Select Ticket(s) applied to the discount code'}}</label>
Expand Down Expand Up @@ -98,64 +79,44 @@
{{/each}}
</div>
<div>
<div class="inline field">
<UiCheckbox
@label={{t "Show more options"}}
@class="toggle"
@checked={{this.showMoreOptions}}
@onChange={{action (mut this.showMoreOptions)}} />
</div>
{{#if this.showMoreOptions}}
<div>{{t 'Set the min and max quantity allowed to purchase per order (Optional)'}}</div>
<div class="{{unless this.device.isMobile 'fields'}}">
<div class="wide field {{if this.device.isMobile 'sixteen' 'five'}}">
<label>{{t 'Min'}}</label>
<Input
@type="number"
@name="min_order"
@min="0"
@value={{this.data.minQuantity}} />
</div>
<div class="wide field {{if this.device.isMobile 'sixteen' 'five'}}">
<label>{{t 'Max'}}</label>
<Input
@type="number"
@name="max_order"
@min="0"
@value={{this.data.maxQuantity}} />
</div>
</div>
<div class="fields">
<div class="wide field {{if this.device.isMobile 'sixteen' 'five'}}">
<label>{{t 'Valid from'}}</label>
<Widgets::Forms::DatePicker
@name="start_date"
@value={{this.data.validFromDate}}
@rangePosition="start"
@onChange={{action "onChange"}} />
<div class="ui hidden divider"></div>
<Widgets::Forms::TimePicker
@name="start_time"
@value={{this.data.validFromTime}}
@onChange={{action "onChange"}} />
<div class="field">
<label>{{t 'Discount valid from'}}</label>
<div class="{{if this.device.isMobile 'grouped'}} fields">
<div class="{{unless this.device.isMobile 'four wide'}} field">
<Widgets::Forms::DatePicker
@name="start_date"
@value={{this.data.validFromDate}}
@rangePosition="start"
@onChange={{action "onChange"}} />
</div>
<div class="{{unless this.device.isMobile 'four wide'}} field">
<Widgets::Forms::TimePicker
@name="start_time"
@value={{this.data.validFromTime}}
@onChange={{action "onChange"}} />
</div>
</div>
<div class="wide field {{if this.device.isMobile 'sixteen' 'five'}}">
<label>{{t 'Expires on'}}</label>
<Widgets::Forms::DatePicker
@type="text"
@name="end_date"
@value={{this.data.validTillDate}}
@rangePosition="end"
@onChange={{action "onChange"}} />
<div class="ui hidden divider"></div>
<Widgets::Forms::TimePicker
@type="text"
@name="end_time"
@value={{this.data.validTillTime}}
@onChange={{action "onChange"}} />
</div>
<div class="field">
<label>{{t 'Discount expires on'}}</label>
<div class="{{if this.device.isMobile 'grouped'}} fields">
<div class="{{unless this.device.isMobile 'four wide'}} field">
<Widgets::Forms::DatePicker
@type="text"
@name="end_date"
@value={{this.data.validTillDate}}
@rangePosition="end"
@onChange={{action "onChange"}} />
</div>
<div class="{{unless this.device.isMobile 'four wide'}} field">
<Widgets::Forms::TimePicker
@type="text"
@name="end_time"
@value={{this.data.validTillTime}}
@onChange={{action "onChange"}} />
</div>
</div>
</div>
{{/if}}
</div>
<div class="field">
<label>{{t 'Discount Link'}}</label>
<div class="ui action input fluid">
Expand Down