Skip to content

Commit

Permalink
Merge pull request #1464 from socialappslab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
yolile authored Jul 27, 2020
2 parents 275dbaf + 81ec6a6 commit 9c34b27
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 deletions.
26 changes: 26 additions & 0 deletions app/v2/controllers/contribution/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
$scope.saveDescription = saveDescription.bind($scope);
$scope.locationToggleEdit = locationToggleEdit.bind($scope);
$scope.budgetToggleEdit = budgetToggleEdit.bind($scope);
$scope.updateTitle = updateTitle.bind($scope);
$scope.saveField = saveField.bind($scope);
$scope.saveTitle = saveTitle.bind($scope);
$scope.getEditorOptions = getEditorOptions.bind($scope);
Expand All @@ -92,11 +93,13 @@
$scope.mergeProposal = mergeProposal.bind($scope);
$scope.goToParentOrChildren = goToParentOrChildren.bind($scope);
$scope.changePeerdocUrl = changePeerdocUrl.bind($scope);
$scope.truncateString = truncateString.bind($scope);

activate();

function activate() {
ModalMixin.init($scope);
$scope.useDescriptionAsTitle = {value: false};
$scope.peerdocMergeView = false;
$scope.peerdocChangesView = false;
$scope.updateFeedback = updateFeedback.bind($scope);
Expand Down Expand Up @@ -2373,6 +2376,25 @@
}
}

function truncateString(str, num) {
// If the length of str is less than or equal to num
// just return str--don't truncate it.
if (str.length <= num) {
return str;
}
// Return str truncated with '...' concatenated to the end of str.
return str.slice(0, num) + '...';
}

function updateTitle() {
if (this.useDescriptionAsTitle.value) {
this.proposal.title = this.truncateString(this.proposal.text, 50)
} else {
this.proposal.title = 'Create a title';
}
this.saveTitle();
}

function saveField(field, newValue) {
let vm = this;
let payload = _.cloneDeep($scope.proposal);
Expand Down Expand Up @@ -2444,6 +2466,10 @@
delete payload.location.geoJson;
}
payload.status = payload.status.toUpperCase();
if(this.useDescriptionAsTitle.value) {
payload.title = this.truncateString(payload.text, 50);
this.proposal.title = payload.title;
}
let rsp = Contributions.contribution($scope.assemblyID, $scope.proposal.contributionId).update(payload).$promise;

rsp.then(
Expand Down
7 changes: 5 additions & 2 deletions app/v2/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,14 @@
{auuid: auuid, cuuid: cuuid},
{reload: true});
}
location.reload();
} else {
// $state.go("v2.public.assembly.auuid.home", {auuid: auuid}, {reload: 'v2.public.assembly.auuid.home'});
window.history.back();
let serverUrl = localStorageService.get('serverBaseUrl');
localStorageService.clearAll();
$state.go("v2.public.assembly.auuid.home", {auuid: auuid}, {reload: true});
localStorageService.set('serverBaseUrl', serverUrl);
}
location.reload();
}

function signout () {
Expand Down
6 changes: 6 additions & 0 deletions app/v2/partials/contribution/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ <h1 class="heading--title" ng-if="!isTitleEdit && !userIsAuthor" style="margin-b
</div>
</div>
</div>
<div ng-if="!isTitleEdit && userIsAuthor && !peerdocIsEnabled" class="row attribution">
<div>
<strong>{{'Use description as title'|translate}}:</strong>
<input id="title-check" type="checkbox" ng-model="useDescriptionAsTitle.value" ng-change="updateTitle()"/>
</div>
</div>

<!--HEADER CUSTOM FIELDS-->
<div class="custom-header-fields" ng-if="customHeaderFields.length > 0">
Expand Down
3 changes: 2 additions & 1 deletion assets/i18n/locale-en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@
"motivational.follow.message3": "Receive notifications when proposals change.",
"Subscribe to Newsletters and Notifications": "Subscribe to Newsletters and Notifications",
"Unsubscribe from Newsletters and Notifications": "Unsubscribe from Newsletters and Notifications",
"Source": "Source",
"Source": "Use this field to provide a source for ideas you see posted on public websites like Facebook, NextDoor , or SeeClick Fix. Enter the name of the website where you saw this idea.",
"Use description as title": "Use description as title",
"Click here": "Click here",
"Upcoming campaigns": "Upcoming campaigns",
"Show comments": "Show comments",
Expand Down
3 changes: 2 additions & 1 deletion assets/i18n/locale-es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@
"motivational.follow.message3": "Recibe notificaciones cuando las propuestas cambian.",
"Subscribe to Newsletters and Notifications": "Subscribirse a los Boletines y a las Notificaciones",
"Unsubscribe from Newsletters and Notifications": "Darse de baja de los Boletines y las Notificaciones",
"Source": "Origen",
"Source": "Use este campo para proporcionar una fuente de ideas que vea publicadas en sitios web públicos como Facebook, NextDoor o SeeClick Fix. Ingrese el nombre del sitio web donde vio esta idea.",
"Use description as title": "Usar la descripción como título",
"Click here": "Clique aquí",
"Upcoming campaigns": "Próximas iniciativas",
"Show comments": "Mostrar comentarios",
Expand Down
3 changes: 2 additions & 1 deletion assets/i18n/locale-es-PY.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@
"motivational.follow.message3": "Recibe notificaciones cuando las propuestas cambian.",
"Subscribe to Newsletters and Notifications": "Subscribirse a los Boletines y a las Notificaciones",
"Unsubscribe from Newsletters and Notifications": "Darse de baja de los Boletines y las Notificaciones",
"Source": "Origen",
"Source": "Use este campo para proporcionar una fuente de ideas que vea publicadas en sitios web públicos como Facebook, NextDoor o SeeClick Fix. Ingrese el nombre del sitio web donde vio esta idea.",
"Use description as title": "Usar la descripción como título",
"Click here": "Clique aquí",
"Upcoming campaigns": "Próximas iniciativas",
"Show comments": "Mostrar comentarios",
Expand Down
3 changes: 2 additions & 1 deletion assets/i18n/locale-pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,8 @@
"motivational.follow.message3": "Receber notificações quando houver mudancas nas propostas.",
"Subscribe to Newsletters and Notifications": "Assinar Newsletters e Notificações",
"Unsubscribe from Newsletters and Notifications": "Cancelar assinatura de Newsletters e Notificações",
"Source": "Fonte",
"Source": "Use este campo para fornecer uma fonte de idéias que você vê postadas em sites públicos como Facebook, NextDoor ou SeeClick Fix. Digite o nome do site em que você viu essa ideia.",
"Use description as title": "Usar la descripción como título",
"Click here": "Clique aqui",
"Upcoming campaigns": "Próximas campanhas",
"Show comments": "Mostrar comentários",
Expand Down

0 comments on commit 9c34b27

Please sign in to comment.