Skip to content

Commit

Permalink
Merge pull request #1195 from hotosm/develop
Browse files Browse the repository at this point in the history
Merge develop into master for version 3.0.3
  • Loading branch information
dakotabenjamin authored Oct 3, 2018
2 parents d8b287a + edd358e commit 139c6de
Show file tree
Hide file tree
Showing 30 changed files with 611 additions and 59 deletions.
87 changes: 86 additions & 1 deletion client/app/admin/edit-project/edit-project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@
// Delete
vm.showDeleteConfirmationModal = false;

// Reset
vm.showResetConfirmationModal = false;

// Private project/add users
vm.addUserEnabled = false;

// Error messages
vm.deleteProjectFail = false;
vm.deleteProjectSuccess = false;
vm.resetProjectFail = false;
vm.resetProjectSuccess = false;
vm.invalidateTasksFail = false;
vm.invalidateTasksSuccess = false;
vm.validateTasksFail = false;
Expand Down Expand Up @@ -369,6 +374,65 @@
})
};

/**
* Set the reset bad imagery confirmation modal to visible/invisible
* @param showModal
*/
vm.showResetBadImageryConfirmation = function(showModal){
vm.showResetBadImageryConfirmationModal = showModal;
};

/**
* Reset all bad imagery tasks on a project
*/
vm.resetBadImageryTasks = function(){
vm.resetBadImageryInProgress = true;
vm.resetBadImageryFail = false;
vm.resetBadImagerySuccess = false;
var resultsPromise = projectService.resetBadImageryTasks(vm.project.projectId);
resultsPromise.then(function(){
// Tasks mapped successfully
vm.resetBadImageryFail = false;
vm.resetBadImagerySuccess = true;
vm.resetBadImageryInProgress = false;
}, function(){
// Tasks not mapped successfully
vm.resetBadImageryFail = true;
vm.resetBadImagerySuccess = false;
vm.resetBadImageryInProgress = false;
})
};

/*
* Set the reset confirmation modal to visible/invisible
* @param showModal
*/
vm.showResetConfirmation = function(showModal){
vm.showResetConfirmationModal = showModal;
if (!showModal && vm.resetProjectSuccess){
$location.path('/');
}
};

/**
* Reset a project
*/
vm.resetProject = function(){
vm.resetProjectFail = false;
vm.resetProjectSuccess = false;
var resultsPromise = projectService.resetProject(vm.project.projectId);
resultsPromise.then(function () {
// Project reset successfully
vm.resetProjectFail = false;
vm.resetProjectSuccess = true;
// Reset the page elements
getProjectMetadata(vm.project.projectId);
}, function(){
// Project not reset successfully
vm.resetProjectFail = true;
vm.resetProjectSuccess = false;
});
};

/**
* Set the invalidate confirmation modal to visible/invisible
Expand Down Expand Up @@ -428,6 +492,27 @@
})
};

/**
* Reset all tasks on a project
*/
vm.resetAllTasks = function(){
vm.resetInProgress = true;
vm.resetTasksFail = false;
vm.resetTasksSuccess = false;
var resultsPromise = projectService.resetAllTasks(vm.project.projectId);
resultsPromise.then(function(){
// Tasks reset successfully
vm.resetTasksFail = false;
vm.resetTasksSuccess = true;
vm.resetInProgress = false;
}, function(){
// Tasks not reset successfully
vm.resetTasksFail = true;
vm.resetTasksSuccess = false;
vm.resetInProgress = false;
})
};

/**
* Set the show message contributors modal to visible/invisible
*/
Expand Down Expand Up @@ -482,7 +567,7 @@
* @param searchValue
*/
vm.getUser = function(searchValue){
var resultsPromise = userService.searchUser(searchValue);
var resultsPromise = userService.searchUser(searchValue, vm.project.id);
return resultsPromise.then(function (data) {
// On success
return data.usernames;
Expand Down
111 changes: 111 additions & 0 deletions client/app/admin/edit-project/edit-project.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,12 @@ <h1 class="section__aside-title">{{ 'In this area' | translate }}</h1>
ng-click="editProjectCtrl.showValidateConfirmation(true)">
{{ 'Validate all tasks' | translate }}
</button>
<div style="margin-top: 5px">
<button class="button button--secondary" type="button"
ng-click="editProjectCtrl.showResetBadImageryConfirmation(true)">
{{ 'Reset all bad imagery tasks' | translate }}
</button>
</div>
</div>
<div class="form__group form__group--section">
<label class="form__label">{{ 'Delete project' | translate }}</label>
Expand All @@ -492,6 +498,17 @@ <h1 class="section__aside-title">{{ 'In this area' | translate }}</h1>
{{ 'Delete project' | translate }}
</button>
</div>
<div class="form__group form__group--section">
<label class="form__label">{{ 'Reset tasks' | translate }}</label>
<p>{{ 'Reset all tasks in the project to ready to map, preserving history.' | translate }}</p>
<div class="alert alert--warning" role="alert">
<p><strong>{{ 'Warning' | translate }}:</strong> {{ 'This cannot be undone.' | translate }}</p>
</div>
<button class="button button--secondary" type="button"
ng-click="editProjectCtrl.showResetConfirmation(true)">
{{ 'Reset tasks' | translate }}
</button>
</div>
<div class="form__group form__group--section">
<label class="form__label">{{ 'Clone project' | translate }}</label>
<p>{{ 'This will clone all descriptions, instructions, metadata etc. The Area of Interest, the tasks and the priority areas will not be cloned. You will have to redraw/import these. Your newly cloned project will be in draft status.' | translate }}</p>
Expand Down Expand Up @@ -635,6 +652,53 @@ <h1 class="modal__title">{{ 'Task mapping' | translate }}</h1>
</section>
<!-- map tasks confirmation modal -->

<!-- reset all bad imagery tasks confirmation modal -->
<section class="modal modal-tm" ng-show="editProjectCtrl.showResetBadImageryConfirmationModal">
<div class="modal__inner">
<header class="modal__header">
<div class="modal__headline">
<h1 class="modal__title">{{ 'Reset Bad Imagery Tasks' | translate }}</h1>
</div>
</header>
<div class="modal__body">
<div ng-hide="editProjectCtrl.resetBadImagerySuccess">
<p>
{{ 'Are you sure you want to mark all bad imagery tasks in this project as ready? You cannot undo this.' | translate }}
</p>
<p>
{{ 'This will mark all bad imagery tasks as ready. Please use this only if you are sure of what you are doing.' | translate }}
</p>
</div>
<p ng-show="editProjectCtrl.resetBadImagerySuccess">
{{ 'The tasks were reset successfully.' | translate }}
</p>
<p ng-show="editProjectCtrl.resetBadImageryFail" class="error">
{{ 'Resetting all the bad imagery tasks failed for an unknown reason.' | translate }}
</p>
</div>
<footer class="modal__footer">
<div ng-hide="editProjectCtrl.resetBadImagerySuccess">
<button class="button button--achromic" type="button"
ng-click="editProjectCtrl.showResetBadImageryConfirmation(false)">{{ 'Cancel' | translate }}
</button>
<button class="button button--base" type="button"
ng-click="editProjectCtrl.resetBadImageryTasks()">{{ 'Reset all bad imagery tasks' | translate }}
</button>
<span ng-show="editProjectCtrl.resetBadImageryInProgress">{{ 'Loading...' | translate }}</span>
</div>
<div ng-show="editProjectCtrl.resetBadImagerySuccess">
<button class="button button--base" type="button"
ng-click="editProjectCtrl.showResetBadImageryConfirmation(false)">{{ 'Close message' | translate }}
</button>
</div>
</footer>
</div>
<button class="modal__button-dismiss" title="{{ 'Close' | translate }}" ng-click="editProjectCtrl.showResetBadImageryConfirmation(false)">
{{ 'Dismiss' | translate }}
</button>
</section>
<!-- reset all bad imagery tasks confirmation modal -->

<!-- invalidate tasks confirmation modal -->
<section class="modal modal-tm" ng-show="editProjectCtrl.showInvalidateConfirmationModal">
<div class="modal__inner">
Expand Down Expand Up @@ -729,6 +793,53 @@ <h1 class="modal__title">{{ 'Task validation' | translate }}</h1>
</section>
<!-- validate tasks confirmation modal -->

<!-- reset tasks confirmation modal -->
<section class="modal modal-tm" ng-show="editProjectCtrl.showResetConfirmationModal">
<div class="modal__inner">
<header class="modal__header">
<div class="modal__headline">
<h1 class="modal__title">{{ 'Task reset' | translate }}</h1>
</div>
</header>
<div class="modal__body">
<div ng-hide="editProjectCtrl.resetTasksSuccess">
<p>
{{ 'Are you sure you want to reset all tasks? You cannot undo this.' | translate }}
</p>
<p>
{{ 'This will reset all tasks to ready to map (preserving existing history). Please use this only if you are sure of what you are doing.' | translate }}
</p>
</div>
<p ng-show="editProjectCtrl.resetTasksSuccess">
{{ 'The tasks were reset successfully.' | translate }}
</p>
<p ng-show="editProjectCtrl.resetTasksFail" class="error">
{{ 'Failed to reset all tasks for an unknown reason.' | translate }}
</p>
</div>
<footer class="modal__footer">
<div ng-hide="editProjectCtrl.resetTasksSuccess">
<button class="button button--achromic" type="button"
ng-click="editProjectCtrl.showResetConfirmation(false)">{{ 'Cancel' | translate }}
</button>
<button class="button button--base" type="button"
ng-click="editProjectCtrl.resetAllTasks()">{{ 'Reset all tasks' | translate }}
</button>
<span ng-show="editProjectCtrl.resetInProgress">{{ 'Resetting...' | translate }}</span>
</div>
<div ng-show="editProjectCtrl.resetTasksSuccess">
<button class="button button--base" type="button"
ng-click="editProjectCtrl.showResetConfirmation(false)">{{ 'Close message' | translate }}
</button>
</div>
</footer>
</div>
<button class="modal__button-dismiss" title="{{ 'Close' | translate }}" ng-click="editProjectCtrl.showResetConfirmation(false)">
{{ 'Dismiss' | translate }}
</button>
</section>
<!-- reset tasks confirmation modal -->

<!-- message contributors modal -->
<section class="modal modal-tm" ng-show="editProjectCtrl.showMessageContributorsModal">
<div class="modal__inner">
Expand Down
26 changes: 14 additions & 12 deletions client/app/components/project-chat/project-chat.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

angular
.module('taskingManager')
.controller('projectChatController', ['$scope', '$anchorScroll', '$location', '$timeout', '$interval', 'messageService', 'userService', projectChatController])
.controller('projectChatController', ['$scope', '$anchorScroll', '$location', '$timeout', '$interval', 'messageService', 'userService', 'configService', projectChatController])
.directive('projectChat', projectChatDirective);

/**
Expand All @@ -34,14 +34,15 @@
return directive;
}

function projectChatController($scope, $anchorScroll, $location, $timeout, $interval, messageService, userService) {
function projectChatController($scope, $anchorScroll, $location, $timeout, $interval, messageService, userService, configService) {

var vm = this;
vm.projectId = 0;
vm.author = '';
vm.message = '';
vm.messages = [];
vm.maxlengthComment = 250;
vm.maxlengthComment = configService.maxChatLength;
vm.suggestedUsers = [];

vm.hasScrolled = false;

Expand Down Expand Up @@ -112,17 +113,18 @@
* @param search
*/
vm.searchUser = function (search) {
// If the search is empty, do nothing.
if (!search || search.length === 0) {
vm.suggestedUsers = [];
return $q.resolve(vm.suggestedUsers);
}

// Search for a user by calling the API
var resultsPromise = userService.searchUser(search);
var resultsPromise = userService.searchUser(search, parseInt(vm.projectId, 10));
return resultsPromise.then(function (data) {
// On success
vm.usernames = [];
if (data.usernames) {
for (var i = 0; i < data.usernames.length; i++) {
vm.usernames.push({'label': data.usernames[i]});
}
}
return data.usernames;
vm.suggestedUsers = data.users;
return vm.suggestedUsers;
}, function () {
// On error
});
Expand All @@ -135,7 +137,7 @@
vm.formatUserTag = function (item) {
// Format the user tag by wrapping into brackets so it is easier to detect that it is a username
// especially when there are spaces in the username
return '@[' + item.label + ']';
return '@[' + item.username + ']';
};

/**
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/project-chat/project-chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
mentio-typed-text="typedTerm"
mentio-search="projectChatCtrl.searchUser(term)"
mentio-select="projectChatCtrl.formatUserTag(item)"
mentio-items="projectChatCtrl.usernames | filter:label:typedTerm"
mentio-items="projectChatCtrl.suggestedUsers"
mentio-template-url="/app/project/user-suggestions-menu.html"
ng-model="projectChatCtrl.message"></textarea>
<p>{{ projectChatCtrl.maxlengthComment - projectChatCtrl.message.length }}
{{ 'characters remaining' | translate }}
Expand Down
23 changes: 12 additions & 11 deletions client/app/project/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
vm.lockedByCurrentUserVectorLayer = null;
vm.map = null;
vm.user = null;
vm.maxlengthComment = 500;
vm.maxlengthComment = configService.maxCommentLength;
vm.taskUrl = '';

// tab and view control
Expand Down Expand Up @@ -67,7 +67,7 @@

//bound from the html
vm.comment = '';
vm.usernames = [];
vm.suggestedUsers = [];

//table sorting control
vm.propertyName = 'username';
Expand Down Expand Up @@ -1540,17 +1540,18 @@
* @param search
*/
vm.searchUser = function (search) {
// If the search is empty, do nothing.
if (!search || search.length === 0) {
vm.suggestedUsers = [];
return $q.resolve(vm.suggestedUsers);
}

// Search for a user by calling the API
var resultsPromise = userService.searchUser(search);
var resultsPromise = userService.searchUser(search, vm.projectData ? parseInt(vm.projectData.projectId, 10) : null);
return resultsPromise.then(function (data) {
// On success
vm.usernames = [];
if (data.usernames) {
for (var i = 0; i < data.usernames.length; i++) {
vm.usernames.push({'label': data.usernames[i]});
}
}
return data.usernames;
vm.suggestedUsers = data.users;
return vm.suggestedUsers;
}, function () {
// On error
});
Expand All @@ -1563,7 +1564,7 @@
vm.formatUserTag = function (item) {
// Format the user tag by wrapping into brackets so it is easier to detect that it is a username
// especially when there are spaces in the username
return '@[' + item.label + ']';
return '@[' + item.username + ']';
};
}
})
Expand Down
Loading

0 comments on commit 139c6de

Please sign in to comment.