added 260907 version of worker toolkit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import Ember from 'ember';
|
||||
import BackNavigateable from 'flaredown/mixins/back-navigateable';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
|
||||
const {
|
||||
get,
|
||||
computed,
|
||||
Controller,
|
||||
String: {
|
||||
htmlSafe,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(BackNavigateable, SearchableDropdown, {
|
||||
closeSymbol: htmlSafe('✕ '),
|
||||
|
||||
randomTrackables: computed(function() {
|
||||
return this.randomSearch('topic');
|
||||
}),
|
||||
|
||||
performSearch(term, resolve, reject) {
|
||||
this
|
||||
.searchByTerm('topic', term)
|
||||
.then(function() { resolve(...arguments); }, reject);
|
||||
},
|
||||
|
||||
manipulateTopic(topic, action) {
|
||||
const model = get(this, 'model');
|
||||
|
||||
model[action](topic);
|
||||
model.save();
|
||||
},
|
||||
|
||||
actions: {
|
||||
addTopic(topic) {
|
||||
this.manipulateTopic(topic, 'addTopic');
|
||||
},
|
||||
|
||||
removeTopic(topic) {
|
||||
this.manipulateTopic(topic, 'removeTopic');
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import Ember from 'ember';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
import NavbarSearchable from 'flaredown/mixins/navbar-searchable';
|
||||
|
||||
const {
|
||||
get,
|
||||
set,
|
||||
computed,
|
||||
Controller,
|
||||
getProperties,
|
||||
setProperties,
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(SearchableDropdown, NavbarSearchable, {
|
||||
page: 1,
|
||||
queryParams: ['following', 'query'],
|
||||
following: null,
|
||||
querySearch: '',
|
||||
foundTopics: null,
|
||||
|
||||
myTopicsText: computed('model.topicFollowing.topicsCount', function() {
|
||||
return `My topics (${get(this, 'model.topicFollowing.topicsCount')})`;
|
||||
}),
|
||||
|
||||
randomTrackables: computed(function() {
|
||||
return this.randomSearch('topic');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
crossedTheLine(above) {
|
||||
if (above) {
|
||||
let { page, model, query } = getProperties(this, 'page', 'model', 'query');
|
||||
let posts = get(model, 'posts');
|
||||
|
||||
set(this, 'loadingPosts', true);
|
||||
|
||||
page += 1;
|
||||
|
||||
this
|
||||
.store
|
||||
.query('post', { page, query })
|
||||
.then(newPosts => {
|
||||
setProperties(this, { page, loadingPosts: false });
|
||||
|
||||
posts.pushObjects(newPosts.toArray());
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import Ember from 'ember';
|
||||
import BackNavigateable from 'flaredown/mixins/back-navigateable';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
|
||||
const {
|
||||
get,
|
||||
computed,
|
||||
Controller,
|
||||
getProperties,
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(BackNavigateable, SearchableDropdown, {
|
||||
disabled: computed('model.{body,title,topics.[]}', function() {
|
||||
const { body, title, topics } = getProperties(get(this, 'model'), 'body', 'title', 'topics');
|
||||
|
||||
return !(body && title && topics.length);
|
||||
}),
|
||||
|
||||
randomTrackables: computed(function() {
|
||||
return this.randomSearch('topic');
|
||||
}),
|
||||
|
||||
performSearch(term, resolve, reject) {
|
||||
this
|
||||
.searchByTerm('topic', term)
|
||||
.then(function() { resolve(...arguments); }, reject);
|
||||
},
|
||||
|
||||
actions: {
|
||||
addTopic(topic) {
|
||||
get(this, 'model').addTopic(topic);
|
||||
},
|
||||
|
||||
savePost() {
|
||||
get(this, 'model')
|
||||
.save()
|
||||
.then(post => this.transitionToRoute('posts.show', post));
|
||||
},
|
||||
|
||||
removeTopic(topic) {
|
||||
get(this, 'model').removeTopic(topic);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
import Ember from 'ember';
|
||||
import PostableGetable from 'flaredown/mixins/postable-getable';
|
||||
import BackNavigateable from 'flaredown/mixins/back-navigateable';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
import NavbarSearchable from 'flaredown/mixins/navbar-searchable';
|
||||
|
||||
const {
|
||||
set,
|
||||
Controller,
|
||||
getProperties,
|
||||
setProperties,
|
||||
computed: {
|
||||
sort,
|
||||
alias,
|
||||
},
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(PostableGetable, BackNavigateable, SearchableDropdown, NavbarSearchable, {
|
||||
page: 1,
|
||||
postablesSort: ['createdAt:desc'],
|
||||
|
||||
notifications: service(),
|
||||
|
||||
postables: sort('model', 'postablesSort'),
|
||||
screenName: alias('session.currentUser.profile.screenName'),
|
||||
|
||||
actions: {
|
||||
crossedTheLine(above) {
|
||||
if (above) {
|
||||
let { page, model } = getProperties(this, 'page', 'model');
|
||||
|
||||
set(this, 'loadingPostables', true);
|
||||
|
||||
page += 1;
|
||||
|
||||
this.getPostables(page).then(postables => {
|
||||
model.pushObjects(postables);
|
||||
|
||||
setProperties(this, { page, loadingPostables: false });
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import Ember from 'ember';
|
||||
import BackNavigateable from 'flaredown/mixins/back-navigateable';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
import NavbarSearchable from 'flaredown/mixins/navbar-searchable';
|
||||
|
||||
const {
|
||||
get,
|
||||
set,
|
||||
isEmpty,
|
||||
computed,
|
||||
Controller,
|
||||
getProperties,
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
computed: {
|
||||
alias,
|
||||
},
|
||||
$,
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(BackNavigateable, SearchableDropdown, NavbarSearchable, {
|
||||
ajax: service(),
|
||||
notifications: service(),
|
||||
session: service(),
|
||||
|
||||
queryParams: ['anchor'],
|
||||
|
||||
post: alias('model'),
|
||||
anchor: null,
|
||||
|
||||
disabled: computed('newComment.body', function() {
|
||||
return isEmpty(get(this, 'newComment.body'));
|
||||
}),
|
||||
|
||||
actions: {
|
||||
submitComment() {
|
||||
const { post, store, newComment } = getProperties(this, 'post', 'store', 'newComment');
|
||||
|
||||
set(newComment, 'post', post);
|
||||
get(post, 'comments').pushObject(newComment);
|
||||
|
||||
newComment
|
||||
.save()
|
||||
.then(() => {
|
||||
set(this, 'newComment', store.createRecord('comment'));
|
||||
});
|
||||
|
||||
$('textarea').blur();
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import Ember from 'ember';
|
||||
import BackNavigateable from 'flaredown/mixins/back-navigateable';
|
||||
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
|
||||
import NavbarSearchable from 'flaredown/mixins/navbar-searchable';
|
||||
|
||||
const {
|
||||
get,
|
||||
set,
|
||||
computed,
|
||||
observer,
|
||||
Controller,
|
||||
getProperties,
|
||||
setProperties,
|
||||
run: {
|
||||
debounce,
|
||||
},
|
||||
inject: {
|
||||
service,
|
||||
},
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend(BackNavigateable, SearchableDropdown, NavbarSearchable, {
|
||||
session: service(),
|
||||
query: '',
|
||||
|
||||
searchFieldObserver: observer('query', function() {
|
||||
debounce(this, this.searchPosts, 200);
|
||||
}),
|
||||
|
||||
isFollowed: computed('model.topicFollowing.updatedAt', function() {
|
||||
const { id, type, topicFollowing } = getProperties(get(this, 'model'), 'id', 'type', 'topicFollowing');
|
||||
|
||||
return get(topicFollowing, `${type}Ids`).includes(parseInt(id));
|
||||
}),
|
||||
|
||||
searchPosts() {
|
||||
const page = 1;
|
||||
const { model, query } = getProperties(this, 'model', 'query');
|
||||
const { id, type } = getProperties(model, 'id', 'type');
|
||||
|
||||
this
|
||||
.store
|
||||
.query('post', { id, type, query, page })
|
||||
.then(posts => setProperties(this, { page, 'model.posts': posts.toArray() }));
|
||||
},
|
||||
|
||||
actions: {
|
||||
toggleTopicFollowing() {
|
||||
const { model, isFollowed } = getProperties(this, 'model', 'isFollowed');
|
||||
const { id, type, topicFollowing } = getProperties(model, 'id', 'type', 'topicFollowing');
|
||||
|
||||
get(topicFollowing, `${type}Ids`)[isFollowed ? 'removeObject' : 'addObject'](parseInt(id));
|
||||
|
||||
topicFollowing.save();
|
||||
},
|
||||
|
||||
crossedTheLine(above) {
|
||||
if (above) {
|
||||
const { model, query } = getProperties(this, 'model', 'query');
|
||||
let { id, page, type, posts } = getProperties(model, 'id', 'page', 'type', 'posts');
|
||||
|
||||
set(this, 'loadingTopics', true);
|
||||
|
||||
page += 1;
|
||||
|
||||
this
|
||||
.store
|
||||
.query('post', { id, type, query, page })
|
||||
.then(newPosts => {
|
||||
setProperties(this, { 'model.page': page, loadingTopics: false });
|
||||
|
||||
posts.pushObjects(newPosts.toArray());
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user