0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

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> <label for="label-input">Labels</label>
<GhMemberLabelInput @onChange={{action "setLabels"}} @labels={{this.member.labels}} @triggerId="label-input" data-test-input="" /> <GhMemberLabelInput @onChange={{action "setLabels"}} @labels={{this.member.labels}} @triggerId="label-input" data-test-input="" />
</GhFormGroup> </GhFormGroup>
<GhFormGroup @errors={{this.member.errors}} @hasValidated={{this.member.hasValidated}} @property="note" @classNames="mb0 gh-member-note"> <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> <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" <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> <div class="mb2">This member doesn't have subscriptions.</div>
{{#unless this.member.isNew}} {{#unless this.member.isNew}}
{{#if this.isAddComplimentaryAllowed}} {{#if this.isAddComplimentaryAllowed}}
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}> {{#if this.isCreatingComplimentary}}
<span>{{svg-jar "add"}} Add complimentary subscription</span> Loading...
</button> {{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}} {{/if}}
{{/unless}} {{/unless}}
</div> </div>
@ -181,9 +185,13 @@
{{/each}} {{/each}}
{{#if this.isAddComplimentaryAllowed}} {{#if this.isAddComplimentaryAllowed}}
<div class="gh-memberproduct-list-footer"> <div class="gh-memberproduct-list-footer">
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}> {{#if this.isCreatingComplimentary}}
<span>{{svg-jar "add"}} Add complimentary subscription</span> Loading...
</button> {{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> </div>
{{/if}} {{/if}}
</div> </div>

View file

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

View file

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