Skip to content

Commit

Permalink
collections working - remaining - test value display and select all
Browse files Browse the repository at this point in the history
  • Loading branch information
willdoran committed Nov 13, 2015
1 parent 00399eb commit 8737dc0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
24 changes: 14 additions & 10 deletions app/post/controllers/post-detail-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = [
'$scope',
'$rootScope',
'post',
'$translate',
'$q',
Expand All @@ -19,6 +20,7 @@ module.exports = [
'Notify',
function (
$scope,
$rootScope,
post,
$translate,
$q,
Expand Down Expand Up @@ -162,11 +164,18 @@ function (
});
};

$scope.editableCollections = CollectionEndpoint.editableByMe();
$scope.refreshCollections = function () {
$scope.editableCollections = CollectionEndpoint.editableByMe();
};
$scope.refreshCollections();
$scope.postInCollection = function (collection) {
return _.contains($scope.post.sets, String(collection.id));
};

$scope.toggleCreateCollection = function () {
$scope.showNewCollectionInput = !$scope.showNewCollectionInput
};

$scope.toggleCollection = function (selectedCollection) {
if (_.contains($scope.post.sets, String(selectedCollection.id))) {
$scope.removeFromCollection(selectedCollection);
Expand Down Expand Up @@ -242,15 +251,10 @@ function (
CollectionEndpoint.save(collection)
.$promise
.then(function (collection) {
$translate('notify.collection.created_collection', {collection: collection})
.then(function (message) {
$scope.addToCollection(collection);
$rootScope.$broadcast('event:collection:update');
$scope.newCollection = '';
$scope.toggleCreateCollection();
refreshCollections();
Notify.showNotificationSlider(message);
});
$scope.toggleCreateCollection();
$scope.newCollection = '';
$scope.refreshCollections();
$scope.addToCollection(collection);
}, function (errorReponse) {
Notify.showApiErrors(errorResponse);
});
Expand Down
13 changes: 10 additions & 3 deletions app/post/directives/post-preview-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function (
scope.newCollection = '';
scope.getRoleDisplayName = RoleHelper.getRole;

scope.editableByMeCopy = [];

// Ensure completes stages array is numeric
scope.post.completed_stages = scope.post.completed_stages.map(function (stageId) {
return parseInt(stageId);
Expand Down Expand Up @@ -98,6 +100,7 @@ function (
return 'Everyone';
};

// TODO all collection code should be moved into a separate standalone widget
scope.postInCollection = function (collection) {
return _.contains(scope.post.sets, String(collection.id));
};
Expand Down Expand Up @@ -139,17 +142,21 @@ function (
Notify.showApiErrors(errorResponse);
});
};

/*
scope.searchCollections = function (query) {
CollectionEndpoint.query(query)
.$promise
.then(function (collection) {

.then(function (result) {
scope.
}, function (errorResponse) {
Notify.showApiErrors(errorResponse);
});
};
scope.clearSearch = function() {
scope.editableCollection = scope.editableCollectionCopy;
};
*/
scope.createNewCollection = function (collectionName) {
var collection = {
'name': collectionName,
Expand Down

0 comments on commit 8737dc0

Please sign in to comment.