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

Added segmented post access setting to labs menu

refs https://github.com/TryGhost/Team/issues/801

- adds the renewed product specific post access setting to new labs post settings sidebar
This commit is contained in:
Rishabh 2021-06-28 15:36:35 +05:30 committed by Rishabh Garg
parent f9a25d4e41
commit c97be22854
2 changed files with 55 additions and 5 deletions

View file

@ -80,10 +80,43 @@
{{#if this.showVisibilityInput}} {{#if this.showVisibilityInput}}
<div class="form-group"> {{#if (feature "multipleProducts")}}
<label for="visibility-input">Post access</label> <GhFormGroup @errors={{this.post.errors}} @hasValidated={{this.post.hasValidated}} @property="visibility">
<GhPsmVisibilityInput @post={{this.post}} @triggerId="visibility-input" /> <label for="visibility-input">Post access</label>
</div> <div
class="gh-radio {{if this.post.isPublic "active"}}"
{{on "click" (action "setVisibility" "public")}}
>
<div class="gh-radio-button"></div>
<div class="gh-radio-content">
<div class="gh-radio-label">Public</div>
</div>
</div>
<div
class="gh-radio {{if (not this.post.isPublic) "active"}}"
{{on "click" (action "setVisibility" this.post.visibilitySegment)}}
>
<div class="gh-radio-button"></div>
<div class="gh-radio-content">
<div class="gh-radio-label">Members-only</div>
<div class="gh-radio-desc">
<GhMembersSegmentSelect
@segment={{this.post.visibilitySegment}}
@onChange={{action "setVisibility"}}
@renderInPlace={{true}}
@hideOptionsWhenAllSelected={{true}}
/>
</div>
</div>
</div>
<GhErrorMessage @errors={{this.post.errors}} @property="visibility" class="no-selection" data-test-error="visibility" />
</GhFormGroup>
{{else}}
<div class="form-group">
<label for="visibility-input">Post access</label>
<GhPsmVisibilityInput @post={{this.post}} @triggerId="visibility-input" />
</div>
{{/if}}
{{/if}} {{/if}}

View file

@ -146,6 +146,23 @@ export default Component.extend({
}); });
}, },
async setVisibility(segment) {
this.post.set('visibility', segment);
try {
await this.post.validate({property: 'visibility'});
if (this.post.changedAttributes().visibility) {
await this.savePostTask.perform();
}
} catch (e) {
if (!e) {
// validation error
return;
}
throw e;
}
},
setPublishedAtBlogDate(date) { setPublishedAtBlogDate(date) {
let post = this.post; let post = this.post;
let dateString = moment(date).format('YYYY-MM-DD'); let dateString = moment(date).format('YYYY-MM-DD');