2021-05-14 18:01:14 +03:00
|
|
|
import Component from '@ember/component';
|
2022-02-01 12:34:03 +03:00
|
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
import {action, computed} from '@ember/object';
|
2021-05-14 18:01:14 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
const VISIBILITIES = [
|
|
|
|
{label: 'Public', name: 'public'},
|
|
|
|
{label: 'Members only', name: 'members'},
|
|
|
|
{label: 'Paid-members only', name: 'paid'}
|
|
|
|
];
|
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@classic
|
|
|
|
export default class GhPsmVisibilityInput extends Component {
|
2022-02-01 20:03:45 +03:00
|
|
|
@service settings;
|
2022-10-07 16:23:21 +03:00
|
|
|
|
2021-05-14 18:01:14 +03:00
|
|
|
// public attrs
|
2022-02-01 12:34:03 +03:00
|
|
|
post = null;
|
2021-05-14 18:01:14 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@computed('post.visibility')
|
|
|
|
get selectedVisibility() {
|
2022-10-07 16:23:21 +03:00
|
|
|
return this.get('post.visibility') || this.settings.defaultContentVisibility;
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2021-05-14 18:01:14 +03:00
|
|
|
|
|
|
|
init() {
|
2022-02-01 12:34:03 +03:00
|
|
|
super.init(...arguments);
|
2021-08-23 10:10:59 +03:00
|
|
|
this.availableVisibilities = [...VISIBILITIES];
|
2022-05-16 18:25:03 +03:00
|
|
|
this.availableVisibilities.push(
|
|
|
|
{label: 'Specific tier(s)', name: 'tiers'}
|
|
|
|
);
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2021-05-14 18:01:14 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@action
|
|
|
|
updateVisibility(newVisibility) {
|
|
|
|
this.post.set('visibility', newVisibility);
|
|
|
|
if (newVisibility !== 'tiers') {
|
|
|
|
this.post.set('tiers', []);
|
2021-05-14 18:01:14 +03:00
|
|
|
}
|
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|