Added loading for assigning comped subscription to member

no refs

Adds loading indicator when member is being saved with new complimentary price
This commit is contained in:
Rishabh 2021-05-19 23:17:59 +05:30
parent f9f925d923
commit d3023e8b52
3 changed files with 22 additions and 7 deletions

View File

@ -74,7 +74,7 @@
<label for="label-input">Labels</label>
<GhMemberLabelInput @onChange={{action "setLabels"}} @labels={{this.member.labels}} @triggerId="label-input" data-test-input="" />
</GhFormGroup>
<GhFormGroup @errors={{this.member.errors}} @hasValidated={{this.member.hasValidated}} @property="note" @classNames="mb0 gh-member-note">
<label for="member-note">Note <span class="midgrey-l2 fw4">(not visible to member)</span></label>
<GhTextarea @id="member-note" @name="note" @class="gh-member-details-textarea" @tabindex="3"
@ -110,9 +110,13 @@
<div class="mb2">This member doesn't have subscriptions.</div>
{{#unless this.member.isNew}}
{{#if this.isAddComplimentaryAllowed}}
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
<span>{{svg-jar "add"}} Add complimentary subscription</span>
</button>
{{#if this.isCreatingComplimentary}}
Loading...
{{else}}
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
<span>{{svg-jar "add"}} Add complimentary subscription</span>
</button>
{{/if}}
{{/if}}
{{/unless}}
</div>
@ -181,9 +185,13 @@
{{/each}}
{{#if this.isAddComplimentaryAllowed}}
<div class="gh-memberproduct-list-footer">
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
<span>{{svg-jar "add"}} Add complimentary subscription</span>
</button>
{{#if this.isCreatingComplimentary}}
Loading...
{{else}}
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
<span>{{svg-jar "add"}} Add complimentary subscription</span>
</button>
{{/if}}
</div>
{{/if}}
</div>

View File

@ -79,6 +79,11 @@ export default class extends Component {
return null;
}
get isCreatingComplimentary() {
const {comped} = this.member.changedAttributes() || {};
return comped && comped[0] === false && comped[1] === true && this.args.isSaveRunning;
}
@action
setProperty(property, value) {
this.args.setProperty(property, value);
@ -103,6 +108,7 @@ export default class extends Component {
continueSubscription(subscriptionId) {
this.continueSubscriptionTask.perform(subscriptionId);
}
@action
addCompedSubscription() {
this.args.setProperty('comped', true);

View File

@ -32,6 +32,7 @@
@scratchMember={{this.scratchMember}}
@setProperty={{this.setProperty}}
@saveMember={{this.save}}
@isSaveRunning={{this.saveTask.isRunning}}
@isLoading={{this.isLoading}} />
</form>