Skip to content

Commit

Permalink
Merge pull request #616 from socialappslab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
cdparra authored Apr 30, 2017
2 parents 24e553e + acaefe3 commit a1b4ee6
Show file tree
Hide file tree
Showing 34 changed files with 482 additions and 187 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Before running the App, you will need to do the following:
$ apt-get install nodejs
$ apt-get install npm
```

2. Using NPM, install [Bower package manager](http://bower.io)

```ssh
Expand All @@ -28,11 +28,10 @@ Before running the App, you will need to do the following:

4. Install the CSS authoring framework [Compass](http://compass-style.org) (you will need [Ruby first](http://www.ruby-lang.org/en/downloads/))

```ssh
$ apt-get install ruby ruby-dev
$ gem update --system
$ gem install compass
```
$ apt-get install ruby ruby-dev
$ gem update --system
$ gem install compass


5. Install the [Sass language](http://sass-lang.com)

Expand Down Expand Up @@ -103,4 +102,4 @@ git config --global url."https://".insteadOf git://
$ grunt jsdoc
```

Then just open `docs/index.html` in your browser.
Then just open `docs/index.html` in your browser.
22 changes: 20 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,33 @@
url: '/contributions?type&from',
templateUrl: 'app/v2/partials/contribution/all.html',
controller: 'v2.ProposalsCtrl'
}).state('v2.campaign', {
})
.state('v2.campaign', {
url: '/campaign',
abstract: true,
template: '<div ui-view></div>'
}).state('v2.campaign.cuuid', {
})
.state('v2.campaign.cuuid', {
url: '/:cuuid',
abstract: true,
template: '<div ui-view></div>'
})
.state('v2.campaign.cuuid.dashboard', {
url: '',
controller: 'v2.CampaignDashboardCtrl',
templateUrl: 'app/v2/partials/campaign/dashboard.html',
})
// open working group dashboard
.state('v2.campaign.cuuid.group', {
url: '/group',
abstract: true,
template: '<div ui-view></div>'
})
.state('v2.campaign.cuuid.group.gid', {
url: '/:gid',
controller: 'v2.WorkingGroupDashboardCtrl',
templateUrl: 'app/v2/partials/working-group/dashboard.html',
})
.state('v2.proposal', {
url: '/proposal',
abstract: true,
Expand Down
4 changes: 3 additions & 1 deletion app/services/appCivistService.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ appCivistApp.factory('WorkingGroups', function($resource, $translate, localStora
},

workingGroupByUUID: function(uuid) {
return $resource(getServerBaseUrl(localStorageService) + '/group/:uuid', { uuid: uuid });
return $resource(getServerBaseUrl(localStorageService) + '/public/group/:uuid', { uuid: uuid });
}
};
});
Expand Down Expand Up @@ -1099,6 +1099,7 @@ appCivistApp.factory('Space', ['$resource', 'localStorageService', 'Contribution
query.type = type;
query.pageSize = 16;
if (isAnonymous) {
// if the space is of type working group, then only published contributions are returned
if (type === 'DISCUSSION') {
rsp = Contributions.contributionInResourceSpaceByUUID(target.frsUUID).get(query);
} else {
Expand Down Expand Up @@ -2521,6 +2522,7 @@ appCivistApp.factory('Editor', ['$resource', 'localStorageService', 'FileUploade
images_upload_credentials: true,
image_advtab: true,
image_title: true,
statusbar: false,
automatic_uploads: true,
file_picker_types: 'image',
imagetools_cors_hosts: ['s3-us-west-1.amazonaws.com'],
Expand Down
9 changes: 8 additions & 1 deletion app/v2/controllers/assembly/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$scope.fetchAssembly = fetchAssembly.bind($scope);
$scope.fetchConfigs = fetchConfigs.bind($scope);
$scope.signout = signout.bind($scope);
$scope.redirectCampaign = redirectCampaign.bind($scope);

activate();

Expand Down Expand Up @@ -220,6 +221,12 @@
location.reload();
});
}

function redirectCampaign(assembly, campaign) {
///#/v2/assembly/{{assembly.assemblyId}}/campaign/{{campaign.campaignId}}
$state.go('v2.assembly.aid.campaign.cid', { aid: assembly.assemblyId, cid: campaign.campaignId }, { reload: true });
}

}

}());
}());
19 changes: 10 additions & 9 deletions app/v2/controllers/campaign/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
activate();

function activate() {
console.log("campaignDashboard");
// Example http://localhost:8000/#/v2/assembly/8/campaign/56c08723-0758-4319-8dee-b752cf8004e6
var pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
$scope.isAnonymous = false;
Expand All @@ -37,8 +38,8 @@
$scope.showPagination = false;
$scope.sorting = "date_desc";

$scope.membersCommentCounter = {value: 0};
$scope.publicCommentCounter = {value: 0};
$scope.membersCommentCounter = { value: 0 };
$scope.publicCommentCounter = { value: 0 };

// TODO: add pagination to Ideas
//$scope.pageSizeIdea = 16;
Expand Down Expand Up @@ -195,7 +196,7 @@
});
}

function loadPublicCommentCount(sid){
function loadPublicCommentCount(sid) {
var res;

if ($scope.isAnonymous) {
Expand All @@ -205,23 +206,23 @@
}

res.$promise.then(
function(data){
function(data) {
$scope.publicCommentCounter.value = data.counter;
},
function (error) {
function(error) {
Notify.show('Error occurred while trying to load working group proposals', 'error');
}
);
}

function loadMembersCommentCount(sid){
function loadMembersCommentCount(sid) {
var res;
res = Space.getCommentCount(sid).get();
res.$promise.then(
function(data){
function(data) {
$scope.membersCommentCounter.value = data.counter;
},
function (error) {
function(error) {
Notify.show('Error occurred while trying to load working group proposals', 'error');
}
);
Expand Down Expand Up @@ -337,4 +338,4 @@
this.vexInstance.close();
}
}
})();
})();
58 changes: 49 additions & 9 deletions app/v2/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
$scope.isCampaignActive = isCampaignActive.bind($scope);
$scope.isGroupActive = isGroupActive.bind($scope);
$scope.fetchGroups = fetchGroups.bind($scope);
$scope.fetchAnonymousGroups = fetchAnonymousGroups.bind($scope);
$scope.needToRefresh = needToRefresh.bind($scope);
$scope.showGroup = showGroup.bind($scope);
activate();

function activate() {
console.log("mainController");
$scope.user = localStorageService.get('user');

if ($scope.user && $scope.user.language) {
Expand All @@ -38,15 +40,19 @@

if ($scope.userIsAuthenticated) {
$scope.currentAssembly = localStorageService.get('currentAssembly');
loadUserData($scope);

if ($state.params && $state.params.cid) {
$scope.currentCampaignId = parseInt($state.params.cid);
}
loadUserData($scope);
} else {
if ($stateParams.cuuid && pattern.test($stateParams.cuuid)) {
if ($state.params && $state.params.cuuid /*&& pattern.test($state.params.cuuid)*/ ) {
$scope.isAnonymous = true;
$scope.isLoginPage = false;
$scope.currentCampaignUuid = $state.params.cuuid;
// load all the puboic working group of the campaign
fetchAnonymousGroups($scope);
} else {

}
}
$scope.updateSmallMenu = updateSmallMenu;
Expand Down Expand Up @@ -78,16 +84,43 @@
if (scope.needToRefresh(myWorkingGroups)) {
Assemblies.setCurrentAssembly(parseInt($state.params.aid)).then(response => {
scope.ongoingCampaigns = localStorageService.get('ongoingCampaigns');
var current = scope.ongoingCampaigns.filter(c => { return c.campaignId == $scope.currentCampaignId });
$scope.currentCampaignUuid = current.length > 0 ? current[0].uuid : '';
scope.assemblies = localStorageService.get('assemblies') || [];
scope.fetchGroups().then(response => {
scope.myWorkingGroups = localStorageService.get('myWorkingGroups');
scope.fetchGroups(scope).then(response => {
// scope.myWorkingGroups = localStorageService.get('myWorkingGroups');
// scope.otherWorkingGroups = localStorageService.get('otherWorkingGroups');
console.log("fetchGroups completed...");
});
});
} else {
scope.ongoingCampaigns = localStorageService.get('ongoingCampaigns');
var current = scope.ongoingCampaigns.filter(c => { return c.campaignId == $scope.currentCampaignId });
$scope.currentCampaignUuid = current.length > 0 ? current[0].uuid : '';
scope.assemblies = localStorageService.get('assemblies') || [];
scope.myWorkingGroups = localStorageService.get('myWorkingGroups');
// scope.otherWorkingGroups = localStorageService.get('otherWorkingGroups');
scope.fetchGroups(scope).then(response => {
console.log("fetchGroups completed...");
});
}

}

/**
*
* @param {Object} scope - component scope
*/
function fetchAnonymousGroups(scope) {
let rsp = WorkingGroups.workingGroupsInCampaignByUUID(scope.currentCampaignUuid).query().$promise;
return rsp.then(
groups => {
localStorageService.set('otherWorkingGroups', groups);
scope.otherWorkingGroups = groups;
return groups;
}
);

}

function updateSmallMenu() {
Expand All @@ -114,6 +147,9 @@

if ($state.params && $state.params.cid) {
$scope.currentCampaignId = parseInt($state.params.cid);
var ongoing = localStorageService.get('ongoingCampaigns');
var current = ongoing.filter(c => { return c.campaignId == $scope.currentCampaignId });
$scope.currentCampaignUuid = current[0].uuid;
}
var isCampaignDashboard = $state.is('v2.assembly.aid.campaign.cid');

Expand Down Expand Up @@ -152,15 +188,19 @@
/**
* Loads the working group associated with the current campaign.
*/
function fetchGroups() {
function fetchGroups(scope) {
let vm = this;
let assembly = localStorageService.get('currentAssembly');
let membershipsInGroups = localStorageService.get('membershipsInGroups');
let rsp = WorkingGroups.workingGroupsInCampaign(assembly.assemblyId, this.currentCampaignId).query().$promise;
return rsp.then(
groups => {
vm.myWorkingGroups = groups.filter(g => _.find(membershipsInGroups, m => m.workingGroup.groupId === g.groupId));
vm.otherWorkingGroups = groups.filter(g => !_.find(membershipsInGroups, m => m.workingGroup.groupId === g.groupId));
localStorageService.set('myWorkingGroups', vm.myWorkingGroups);
localStorageService.set('otherWorkingGroups', vm.otherWorkingGroups);
scope.myWorkingGroups = vm.myWorkingGroups;
scope.otherWorkingGroups = vm.otherWorkingGroups;
return groups;
}
);
Expand Down Expand Up @@ -188,9 +228,9 @@
* @param {Object[]} workingGroups
*/
function needToRefresh(workingGroups) {
if (!workingGroups || workingGroups.length === 0) {
return true;
}
// if (!workingGroups || workingGroups.length === 0) {
// return true;
// }

if ($state.is('v2.assembly.aid.campaign.cid')) {
if (workingGroups) {
Expand Down
17 changes: 12 additions & 5 deletions app/v2/controllers/working-group/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
activate();

function activate() {
console.log("workingGroupDashboard");
ModalMixin.init($scope);
$scope.membersCommentCounter = { value: 0 };
$scope.publicCommentCounter = { value: 0 };
$scope.pageSize = 16;
$scope.type = 'proposal';
$scope.showPagination = false;
$scope.isTopicGroup = false;
$scope.sorting = 'date_desc';
// if the param is uuid then it is an anonymous user
$scope.isAnonymous = false;
Expand All @@ -52,6 +54,8 @@
$scope.fromURL = 'v2/assembly/' + $scope.assemblyID + '/group/' + $scope.groupID;
$scope.isCoordinator = Memberships.isAssemblyCoordinator($scope.assemblyID);
loadAssembly();

loadCampaign();
}

if (!$scope.isAnonymous) {
Expand All @@ -66,7 +70,7 @@
$scope.toggleAllMembers = toggleAllMembers.bind($scope);
$scope.closeAndReload = closeAndReload.bind($scope);

loadCampaign();


$scope.contributionTypeIsSupported = function(type) {
return Campaigns.isContributionTypeSupported(type, $scope);
Expand All @@ -83,10 +87,7 @@

function verifyMembership() {
$scope.userIsMember = Memberships.isMember('group', $scope.groupID);

if ($scope.userIsMember) {
loadWorkingGroup();
}
loadWorkingGroup();
}

function loadWorkingGroup() {
Expand All @@ -103,6 +104,12 @@
$scope.wg.rsID = data.resourcesResourceSpaceId;
$scope.wg.rsUUID = data.resourcesResourceSpaceUUId;
$scope.wg.frsUUID = data.forumResourceSpaceUUId;
$scope.isTopicGroup = data.isTopic;

if ($scope.isTopicGroup) {
// if group is topic, then is OPEN to every assembly member.
$scope.userIsMember = true;
}
loadMembers(data);
loadProposals(data);
loadIdeas(data);
Expand Down
5 changes: 5 additions & 0 deletions app/v2/controllers/working-group/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
}

$scope.setModerationAndMembership = function() {
if ($scope.isTopic) {
console.log("Is Topic");
$scope.newWorkingGroup.profile.supportedMembership = 'OPEN';
}

if ($scope.newWorkingGroup.profile.membership === 'OPEN') {
$scope.newWorkingGroup.profile.supportedMembership = 'OPEN';
} else if ($scope.newWorkingGroup.profile.membership === 'REGISTRATION') {
Expand Down
3 changes: 2 additions & 1 deletion app/v2/directives/contribution-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
components: '=',
isAnonymous: '=',
showIdeaBody: '@',
isCoordinator: '='
isCoordinator: '=',
isTopicGroup: '='
},
templateUrl: '/app/v2/partials/directives/contribution-card.html',
link: function postLink(scope, element, attrs) {
Expand Down
Loading

0 comments on commit a1b4ee6

Please sign in to comment.