Exemplo n.º 1
0
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { reads, empty, bool, not, and } from '@ember/object/computed';

export default Component.extend({
  store: service(),

  account: null,

  subscription: reads('account.subscription'),
  isSubscriptionEmpty: empty('subscription'),
  trial: reads('account.trial'),
  isEducationalAccount: bool('account.education'),
  isNotEducationalAccount: not('isEducationalAccount'),

  isTrial: and('isSubscriptionEmpty', 'isNotEducationalAccount'),
  isManual: bool('subscription.isManual'),
  isManaged: bool('subscription.managedSubscription'),
  isEducation: and('isSubscriptionEmpty', 'isEducationalAccount'),

  invoices: computed('subscription.id', function () {
    let subscriptionId = this.get('subscription.id');
    if (subscriptionId) {
      return this.get('store').query('invoice', { subscription_id: subscriptionId });
    } else {
      return [];
    }
  })
});
Exemplo n.º 2
0
import { empty } from '@ember/object/computed';
import Evented from '@ember/object/evented';
import EmberObject, { set, get, computed } from '@ember/object';
import HasMany from './relationships/has-many';

const Model = EmberObject.extend(Evented, {
  id: null,
  type: null,
  _store: null,

  init() {
    this._super();
    this.identity = { id: this.id, type: this.type };
  },

  disconnected: empty('_store'),

  getKey(field) {
    const cache = get(this, '_storeOrError.cache');
    return cache.retrieveKey(this.identity, field);
  },

  replaceKey(field, value, options) {
    const store = get(this, '_storeOrError');
    store.update(t => t.replaceKey(this.identity, field, value), options);
  },

  getAttribute(field) {
    const cache = get(this, '_storeOrError.cache');
    return cache.retrieveAttribute(this.identity, field);
  },
Exemplo n.º 3
0
export default Controller.extend({
    ghostPaths: service(),
    ajax: service(),
    notifications: service(),
    settings: service(),

    leaveSettingsTransition: null,
    slackArray: null,

    init() {
        this._super(...arguments);
        this.slackArray = [];
    },

    slackSettings: boundOneWay('settings.slack.firstObject'),
    testNotificationDisabled: empty('slackSettings.url'),

    actions: {
        save() {
            this.save.perform();
        },

        updateURL(value) {
            value = typeof value === 'string' ? value.trim() : value;
            this.set('slackSettings.url', value);
            this.get('slackSettings.errors').clear();
        },

        updateUsername(value) {
            value = typeof value === 'string' ? value.trimLeft() : value;
            this.set('slackSettings.username', value);
Exemplo n.º 4
0
  categories: alias('model.categories'),
  category: alias('model.category'),

  categoryDescription: oneWay('category.description'),
  categoryName: oneWay('category.name'),
  categoryParent: oneWay('category.parent.id'),
  categoryPosition: oneWay('category.position'),

  subcategories: sort('category.subcategories', 'categoryPositionSorting'),
  siblingCategories: filter('categories', function(item) {
    return item.get('parent.id') === this.get('category.parent.id');
  }),
  sortedSiblingCategories: sort('siblingCategories', 'categoryPositionSorting'),
  hasSiblingCategories: gt('siblingCategories.length', 1),

  isTopLevelCategory: empty('category.parent'),

  topLevelCategories: filterBy('categories', 'parent', null),
  alphabeticTopLevelCategories: sort('topLevelCategories', 'categoryNameSorting'),

  newCategoryName: '',
  newCategoryDescription: '',
  newCategoryPosition: -1,

  actions: {
    addSubcategory() {
      let newCategory = this.get('store').createRecord('category', {
        name: this.get('newCategoryName'),
        description: this.get('newCategoryDescription'),
        position: this.get('newCategoryPosition'),
        parent: this.get('category')
Exemplo n.º 5
0
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <*****@*****.**>.
//
// https://documize.com

import { empty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Notifier from '../../mixins/notifier';
import Component from '@ember/component';

export default Component.extend(Notifier, {
	documentSvc: service('document'),
	docName: '',
	docExcerpt: '',
	hasNameError: empty('docName'),

	didReceiveAttrs() {
		this._super(...arguments);

		this.set('docName', this.get('document.name'));
		this.set('docExcerpt', this.get('document.excerpt'));
	},

	actions: {
		onSave() {
			if (this.get('hasNameError')) return;
			if (!this.get('permissions.documentEdit')) return;

			this.set('document.name', this.get('docName').trim());
			this.set('document.excerpt', this.get('docExcerpt').trim());
Exemplo n.º 6
0
Arquivo: component.js Projeto: go/ui
  modalService: service('modal'),
  globalStore: service(),

  model: null,
  driver: null,
  onAdd: null,

  loading: true,
  editing: false,
  allNodeDrivers: null,

  needReloadSchema: false,
  reloadingSchema: false,
  schemaReloaded: false,

  showPicker: empty('model.id'),

  actions: {
    switchDriver(name) {
      set(this, 'driver', name);
    },

    saved() {
      const fn = get(this, 'onAdd');
      const model = get(this,'model');

      if ( fn ) {
        fn(model);
      }
    },
  /**
    Returns `true` if the username is not already being used and it is not
    empty.

    @property isAvailable
    @type Boolean
   */
  isAvailable: and('isAvailableOnServer', 'isNotEmpty'),

  /**
    Returns `true` if the username is empty.

    @property isEmpty
    @type Boolean
   */
  isEmpty: empty('username'),

  /**
    Returns `true` if the username is not valid.

    @property isInvalid
    @type Boolean
   */
  isInvalid: not('isValid'),

  /**
    Returns `true` if the username is not empty.

    @property isNotEmpty
    @type Boolean
   */
Exemplo n.º 8
0
import { empty } from '@ember/object/computed';
import Component from '@ember/component';
import Configuration from '@upfluence/ember-upf-utils/configuration';

import layout from './template';

export default Component.extend({
  layout,

  videoUrl: null,

  allowedExtentions: ['mp4,mov,avi,3gp'],
  uploaderHeaders: { Scope: Configuration.scope[0] },

  noVideoUploaded: empty('videoUrl'),

  _buildVideoNode(url, contentType) {
    let container = document.createElement('div');
    let videoNode = document.createElement('video');
    let videoSourceNode = document.createElement('source');

    container.setAttribute('style', 'width: 95%');
    videoNode.setAttribute('width', '100%');
    videoNode.setAttribute('controls', true);
    videoNode.setAttribute('src', url);
    videoSourceNode.setAttribute('src', url);
    videoSourceNode.setAttribute('type', contentType);

    videoNode.appendChild(videoSourceNode);
    container.appendChild(videoNode);
    container.appendChild(document.createElement('br'));
Exemplo n.º 9
0
import $ from 'jquery';
import { isPresent, isNone } from '@ember/utils';
import Service, { inject as service } from '@ember/service';
import { empty } from '@ember/object/computed';
import config from 'watermelon-juice/config/environment';

export default Service.extend({
  store: service(),
  session: service(),
  allSynced: empty("remainingKeys"),

  init() {
    this._super(...arguments);

    this.remainingKeys = this.remainingKeys || [];
  },

  start() {
    setInterval(this.processQueue.bind(this), 5000);
  },

  async loadFromLS(){
    const keys = await localforage.keys();
    keys
      .forEach(async key => {
        const stash = await localforage.getItem(key);
        this.get("store").pushPayload(stash.emberData);
      });
  },

  async enqueue(routeVisit) {
Exemplo n.º 10
0
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <*****@*****.**>.
//
// https://documize.com

import $ from 'jquery';
import { empty } from '@ember/object/computed';
import Component from '@ember/component';
import ModalMixin from '../../mixins/modal';

export default Component.extend(ModalMixin, {
	cancelLabel: "Close",
	actionLabel: "Save",
	busy: false,
	hasNameError: empty('page.title'),
	hasDescError: empty('page.excerpt'),

	didRender() {
		let self = this;
		Mousetrap.bind('esc', function () {
			self.send('onCancel');
			return false;
		});
		Mousetrap.bind(['ctrl+s', 'command+s'], function () {
			self.send('onAction');
			return false;
		});

		$("#page-title").removeClass("is-invalid");
		$("#page-excerpt").removeClass("is-invalid");
Exemplo n.º 11
0
import Component from '@ember/component';
import { empty } from '@ember/object/computed';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import ajax from 'ember-fetch/ajax';

export default Component.extend({
    flashMessages: service(),

    type: '',
    value: '',
    isEditing: false,
    user: null,
    disableSave: empty('user.email'),
    notValidEmail: false,
    prevEmail: '',
    emailIsNull: computed('user.email', function() {
        let email = this.get('user.email');
        return (email == null);
    }),
    emailNotVerified: computed('user.{email,email_verified}', function() {
        let email = this.get('user.email');
        let verified = this.get('user.email_verified');

        return (email != null && !verified);
    }),
    isError: false,
    emailError: '',
    disableResend: false,
    resendButtonText: computed('disableResend', 'user.email_verification_sent', function() {
        if (this.get('disableResend')) {