Пример #1
0
  byPathDidChange: observer('byPath', function () {
    var byPath = get(this, 'byPath');

    if (isEmpty(byPath)) {
      defineProperty(this, 'content', []);
      return;
    }

    defineProperty(this, 'content', mapBy('array', byPath));
  }),
Пример #2
0
import Ember from 'ember';
import Controller from 'ember-controller';
import { mapBy, max } from 'ember-computed';
import { A as emberA } from 'ember-array/utils';
import { tags } from '../utils/dummy-data';
const { RSVP } = Ember;

export default Controller.extend({
  selectedTagIDs: mapBy('selectedTags', 'id'),
  selectedTagNames: mapBy('selectedTags', 'name'),
  maxTagID: max('selectedTagIDs'),

  init() {
    this.set('selectedTags', emberA(tags));
  },

  _findTags(query) {
    let tags = emberA(this.get('selectedTags').filter((tag) => {
      return tag.name.toLowerCase().indexOf(query.toLowerCase()) >= 0;
    }));
    return RSVP.resolve(tags.mapBy('name'));
  },

  actions: {
    findTags(query) {
      return this._findTags(query);
    },

    tag(name) {
      let selectedTags = this.get('selectedTags');
      let tag = selectedTags.findBy('name', name);
Пример #3
0
import Component from 'ember-component';
import computed, {mapBy} from 'ember-computed';
import injectService from 'ember-service/inject';
import {invokeAction} from 'ember-invoke-action';
import moment from 'moment';

export default Component.extend({
    classNames: ['form-group', 'for-select'],

    activeTimezone: null,
    availableTimezones: null,

    clock: injectService(),

    availableTimezoneNames: mapBy('availableTimezones', 'name'),

    hasTimezoneOverride: computed('activeTimezone', 'availableTimezoneNames', function () {
        let activeTimezone = this.get('activeTimezone');
        let availableTimezoneNames = this.get('availableTimezoneNames');

        return !availableTimezoneNames.includes(activeTimezone);
    }),

    selectedTimezone: computed('activeTimezone', 'availableTimezones', 'hasTimezoneOverride', function () {
        let hasTimezoneOverride = this.get('hasTimezoneOverride');
        let activeTimezone = this.get('activeTimezone');
        let availableTimezones = this.get('availableTimezones');

        if (hasTimezoneOverride) {
            return {name: '', label: ''};
        }
    }),

    /**
     * By default, a post will not change its publish state.
     * Only with a user-set value (via setSaveType action)
     * can the post's status change.
     */
    willPublish: boundOneWay('model.isPublished'),
    willSchedule: boundOneWay('model.isScheduled'),
    scheduledWillPublish: boundOneWay('model.isPublished'),

    // set by the editor route and `hasDirtyAttributes`. useful when checking
    // whether the number of tags has changed for `hasDirtyAttributes`.
    previousTagNames: null,

    tagNames: mapBy('model.tags', 'name'),

    postOrPage: computed('model.page', function () {
        return this.get('model.page') ? 'Page' : 'Idea';
    }),

    // countdown timer to show the time left until publish time for a scheduled post
    // starts 15 minutes before scheduled time
    scheduleCountdown: computed('model.status', 'clock.second', 'model.publishedAtUTC', 'model.timeScheduled', function () {
        let status = this.get('model.status');
        let publishTime = this.get('model.publishedAtUTC');

        this.get('clock.second');

        if (this.get('model.timeScheduled') && status === 'scheduled' && publishTime.diff(moment.utc(new Date()), 'minutes', true) < 15) {
            return moment(publishTime).fromNow();
Пример #5
0
    store: injectService(),

    hideUploader: or('theme', 'displayOverwriteWarning'),

    uploadUrl: computed(function () {
        return `${ghostPaths().apiRoot}/themes/upload/`;
    }),

    themeName: computed('theme.{name,package.name}', function () {
        let themePackage = this.get('theme.package');
        let name = this.get('theme.name');

        return themePackage ? `${themePackage.name} - ${themePackage.version}` : name;
    }),

    currentThemeNames: mapBy('model.themes', 'name'),

    fileThemeName: computed('file', function () {
        let file = this.get('file');
        return file.name.replace(/\.zip$/, '');
    }),

    canActivateTheme: computed('theme', function () {
        let theme = this.get('theme');
        return theme && !theme.get('active');
    }),

    actions: {
        validateTheme(file) {
            let themeName = file.name.replace(/\.zip$/, '').replace(/[^\w@.]/gi, '-').toLowerCase();