-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' - Preparing for v3.2 release
- Loading branch information
Showing
153 changed files
with
6,195 additions
and
743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
"expect", | ||
"inject", | ||
"jasmine", | ||
"fixture", | ||
"spyOn", | ||
"describe", | ||
"beforeEach", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/** | ||
* Ushahidi Angular Collection Selector directive | ||
* Drop in directive for managing collections addition for posts | ||
*/ | ||
|
||
module.exports = [ | ||
function ( | ||
) { | ||
var controller = [ | ||
'$scope', | ||
'$rootScope', | ||
'$translate', | ||
'Notify', | ||
'CollectionEndpoint', | ||
'_', | ||
function ( | ||
$scope, | ||
$rootScope, | ||
$translate, | ||
Notify, | ||
CollectionEndpoint, | ||
_ | ||
) { | ||
$scope.showNewCollectionInput = false; | ||
$scope.newCollection = ''; | ||
$scope.editableCollections = []; | ||
|
||
$scope.refreshCollections = function () { | ||
CollectionEndpoint.editableByMe().$promise.then(function (results) { | ||
$scope.editableCollections = results; | ||
}); | ||
}; | ||
|
||
$scope.refreshCollections(); | ||
|
||
$scope.$on('event:collection-selector:update', function () { | ||
$scope.refrehCollections(); | ||
}); | ||
|
||
$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); | ||
} else { | ||
$scope.addToCollection(selectedCollection); | ||
} | ||
}; | ||
|
||
$scope.addToCollection = function (selectedCollection) { | ||
var collectionId = selectedCollection.id, collection = selectedCollection.name; | ||
|
||
CollectionEndpoint.addPost({'collectionId': collectionId, 'id': $scope.post.id}) | ||
.$promise.then(function () { | ||
$translate('notify.collection.add_to_collection', {collection: collection}) | ||
.then(function (message) { | ||
$scope.post.sets.push(String(collectionId)); | ||
Notify.showNotificationSlider(message); | ||
}); | ||
}, function (errorResponse) { | ||
Notify.showApiErrors(errorResponse); | ||
}); | ||
}; | ||
|
||
$scope.removeFromCollection = function (selectedCollection) { | ||
var collectionId = selectedCollection.id, collection = selectedCollection.name; | ||
|
||
CollectionEndpoint.removePost({'collectionId': collectionId, 'id': $scope.post.id}) | ||
.$promise | ||
.then(function () { | ||
$translate('notify.collection.removed_from_collection', {collection: collection}) | ||
.then(function (message) { | ||
$scope.post.sets = _.without($scope.post.sets, String(collectionId)); | ||
Notify.showNotificationSlider(message); | ||
}); | ||
}, function (errorResponse) { | ||
Notify.showApiErrors(errorResponse); | ||
}); | ||
}; | ||
/* | ||
scope.searchCollections = function (query) { | ||
CollectionEndpoint.query(query) | ||
.$promise | ||
.then(function (result) { | ||
}, function (errorResponse) { | ||
Notify.showApiErrors(errorResponse); | ||
}); | ||
}; | ||
scope.clearSearch = function() { | ||
scope.editableCollection = scope.editableCollectionCopy; | ||
}; | ||
*/ | ||
$scope.createNewCollection = function (collectionName) { | ||
var collection = { | ||
'name': collectionName, | ||
'user_id': $rootScope.currentUser.userId | ||
}; | ||
CollectionEndpoint.save(collection) | ||
.$promise | ||
.then(function (collection) { | ||
$scope.toggleCreateCollection(); | ||
$scope.newCollection = ''; | ||
$scope.addToCollection(collection); | ||
|
||
// Where collection selectors can appear multiple times | ||
// it is necessary to force a collection refresh when an update occurs | ||
// on anyone collection selector - to ensure that newly created collections | ||
// are available in all lists on the page. | ||
// TODO: add caching for collections to reduce requests. | ||
$rootScope.$broadcast('event:collection:update'); | ||
}, function (errorResponse) { | ||
Notify.showApiErrors(errorResponse); | ||
}); | ||
}; | ||
|
||
}]; | ||
return { | ||
restrict: 'E', | ||
templateUrl: 'templates/collection-selector/collection-selector.html', | ||
scope: { | ||
post: '=' | ||
}, | ||
controller: controller | ||
}; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Ushahidi Angular Role Selector directive | ||
* Drop in directive for managing roles addition for users | ||
* and posts | ||
*/ | ||
|
||
module.exports = [ | ||
function ( | ||
) { | ||
var controller = [ | ||
'$scope', | ||
'$rootScope', | ||
'$translate', | ||
'Notify', | ||
'RoleEndpoint', | ||
'_', | ||
function ( | ||
$scope, | ||
$rootScope, | ||
$translate, | ||
Notify, | ||
RoleEndpoint, | ||
_ | ||
) { | ||
|
||
RoleEndpoint.query().$promise.then(function (roles) { | ||
$scope.roles = roles; | ||
}); | ||
|
||
$scope.checkIfAllSelected = function () { | ||
return ($scope.roles.length === $scope.post.published_to.length); | ||
}; | ||
|
||
$scope.toggleRole = function (role) { | ||
if (role === 'draft' || role === '') { | ||
$scope.post.published_to = []; | ||
} else if ($scope.checkIfAllSelected()) { | ||
// All check boxes selected, therefore publish to everyone | ||
$scope.post.published_to = []; | ||
} | ||
|
||
$scope.post.status = role === 'draft' ? role : 'published'; | ||
|
||
$scope.toggleRoleFunc({updatedPost: $scope.post}); | ||
}; | ||
|
||
}]; | ||
return { | ||
restrict: 'E', | ||
templateUrl: 'templates/role-selector/role-selector.html', | ||
scope: { | ||
post: '=', | ||
toggleRoleFunc: '&' | ||
}, | ||
controller: controller | ||
}; | ||
}]; |
Oops, something went wrong.