Skip to content

Commit

Permalink
Merge branch 'feature#527' of https://github.com/socialappslab/appciv…
Browse files Browse the repository at this point in the history
…ist-pb-client into feature#527

# By Verena Ojeda (4) and rebearteta (1)
# Via GitHub (5) and Verena Ojeda (1)
* 'feature#527' of https://github.com/socialappslab/appcivist-pb-client:
  Anonymous working group page is added. Other working groups are added in the sidebar. ref #396
  Bugfix.
  CampaignID bugfix. ref #607
  Hide editor status bar (tinymce). ref #550.
  Add isTopic in WG creation
  • Loading branch information
cdparra committed Apr 30, 2017
2 parents d801ad5 + 63b06fb commit cc3cf59
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 47 deletions.
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 });
}

}

}());
}());
1 change: 1 addition & 0 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 Down
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
5 changes: 4 additions & 1 deletion app/v2/controllers/working-group/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
activate();

function activate() {
console.log("workingGroupDashboard");
ModalMixin.init($scope);
$scope.membersCommentCounter = { value: 0 };
$scope.publicCommentCounter = { value: 0 };
Expand Down Expand Up @@ -53,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 @@ -67,7 +70,7 @@
$scope.toggleAllMembers = toggleAllMembers.bind($scope);
$scope.closeAndReload = closeAndReload.bind($scope);

loadCampaign();


$scope.contributionTypeIsSupported = function(type) {
return Campaigns.isContributionTypeSupported(type, $scope);
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
1 change: 1 addition & 0 deletions app/v2/directives/contribution-feedback-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
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
1 change: 1 addition & 0 deletions app/v2/directives/contribution-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
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
13 changes: 7 additions & 6 deletions app/v2/directives/discussion-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
spaceId: '=',
endpointId: '=',
endpoint: '@',
publicBoard: '@'
publicBoard: '@',
isAnonymous: '='
},
templateUrl: '/app/v2/partials/directives/discussion-panel.html',
link: function(scope, element, attrs) {
Expand All @@ -35,7 +36,7 @@
function activate() {
scope.vm = {};
scope.user = localStorageService.get('user');
scope.isAnonymous = !scope.user;
// scope.isAnonymous = !scope.user;
scope.validateCaptchaResponse = validateCaptchaResponse.bind(scope);
scope.setCaptchaResponse = setCaptchaResponse.bind(scope);

Expand Down Expand Up @@ -109,7 +110,7 @@
function loadDiscussions(scope, sid) {
var query = { type: 'DISCUSSION' };
var rsp;
if (!scope.user) {
if (scope.isAnonymous) {
rsp = Contributions.contributionInResourceSpaceByUUID(sid).get(query);
} else {
rsp = Contributions.contributionInResourceSpace(sid).get(query);
Expand All @@ -136,7 +137,7 @@
angular.forEach(discussions, function(d) {
d.rsUUID = d.resourceSpaceUUID;
d.rsID = d.resourceSpaceId;
Space.getContributions(d, 'comment', (!scope.user), {}).then(
Space.getContributions(d, 'comment', (scope.isAnonymous), {}).then(
function(comments) {
d.comments = comments.list;
}
Expand All @@ -151,7 +152,7 @@
return;
}
var rsp;
if (!scope.user) {
if (scope.isAnonymous) {
rsp = Contributions.createAnomymousContribution(endpoint, sid);
} else {
rsp = Contributions.contributionInResourceSpace(sid);
Expand Down Expand Up @@ -195,4 +196,4 @@
);
}
}
}());
}());
15 changes: 8 additions & 7 deletions app/v2/partials/assembly/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h2>{{ 'Campaigns' | translate }}</h2>
<uib-tabset>
<uib-tab index="0" heading="{{'Ongoing campaigns' | translate}}">
<div class="list-group" ng-repeat="campaign in ongoings">
<a ng-if="!isAnonymous && !readAssemblyByShortname" ng-href="/#/v2/assembly/{{assembly.assemblyId}}/campaign/{{campaign.campaignId}}" class="list-group-item">
<a ng-if="!isAnonymous && !readAssemblyByShortname" ng-click="redirectCampaign(assembly, campaign)" class="list-group-item">
<div>
{{campaign.title}}
</div>
Expand Down Expand Up @@ -79,7 +79,7 @@ <h4>{{$index}}. {{group.name}}</h4>
</uib-tab>
<uib-tab index="1" heading="{{'Past campaigns' | translate}}">
<div class="list-group" ng-repeat="campaign in pastCampaigns">
<a ng-if="!isAnonymous && !readAssemblyByShortname" ng-href="/#/v2/assembly/{{assembly.assemblyId}}/campaign/{{campaign.campaignId}}" class="list-group-item">
<a ng-if="!isAnonymous && !readAssemblyByShortname" ng-click="redirectCampaign(assembly, campaign)" class="list-group-item">
<div>
{{campaign.title}}
</div>
Expand Down Expand Up @@ -135,9 +135,9 @@ <h2>{{ 'Assembly Resources' | translate }}</h2>
</p>
<!-- TODO: find a better grid design for these resources -->
<!--<p class="col-lg-6 col-md-6 col-sm-12 col-xs-12" ng-if="resources && resources.length>1">-->
<!--<a ng-href="{{resource.url}}" target="_blank">-->
<!--{{resource.title ? (resource.title.length < 50 ? resource.title : resource.title | limitTo:50 + "...") : resource.type }}-->
<!--</a>-->
<!--<a ng-href="{{resource.url}}" target="_blank">-->
<!--{{resource.title ? (resource.title.length < 50 ? resource.title : resource.title | limitTo:50 + "...") : resource.type }}-->
<!--</a>-->
<!--</p>-->
</div>
</div>
Expand Down Expand Up @@ -180,7 +180,8 @@ <h1>{{"This Assembly is not public" | translate}}</h1>
<uib-tab index="0">
<div class="list-group">
<a ng-href="" class="list-group-item">
<p>{{'To see the content of this assembly, you need to know its short name or its universal unique id' | translate}}</p>
<p>{{'To see the content of this assembly, you need to know its short name or its universal
unique id' | translate}}</p>
</a>
</div>
</uib-tab>
Expand Down Expand Up @@ -218,4 +219,4 @@ <h1>{{"This Assembly is not public" | translate}}</h1>
</div>
</div>
</footer>
</div>
</div>
6 changes: 3 additions & 3 deletions app/v2/partials/campaign/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ <h2 class="heading--header">{{ 'Ideas' | translate}}</h2>
<div class="tab-content">
<div class="tab-pane" ng-class="{'active': activeTab === 'Members'}" ng-if="userIsMember && activeTab === 'Members'">
<discussion-panel class="col-md-12" ng-if="userIsMember" space-id="spaceID" endpoint-id="campaignID"
endpoint="campaign"></discussion-panel>
endpoint="campaign" is-anonymous="isAnonymous"></discussion-panel>
</div>
<div class="tab-pane" ng-class="{'active': activeTab === 'Public'}" ng-if="activeTab === 'Public'">
<discussion-panel ng-if="!isAnonymous" class="col-md-12" space-id="campaign.forumSpaceID" endpoint-id="$parent.campaignID"
endpoint="campaign" public-board="true"></discussion-panel>
endpoint="campaign" public-board="true" is-anonymous="isAnonymous"></discussion-panel>
<discussion-panel ng-if="isAnonymous" class="col-md-12" space-id="campaign.frsUUID" endpoint-id="campaign.uuid"
endpoint="campaign" public-board="true"></discussion-panel>
endpoint="campaign" public-board="true" is-anonymous="isAnonymous"></discussion-panel>
</div>
</div>

Expand Down
Loading

0 comments on commit cc3cf59

Please sign in to comment.