note and journal (ui)

This commit is contained in:
Michele Artini 2021-04-09 15:32:32 +02:00
parent 13fd72b25e
commit b357d25703
6 changed files with 94 additions and 6 deletions

View File

@ -19,6 +19,12 @@
<li class="nav-item" ng-show="org.status == 'approved' && adminMode">
<a href="javascript:void(0)" class="nav-link" ng-class="{'active': currentTab == 3}" ng-click="gotoTab(3)">Conflicts <span class="badge badge-danger ml-2" ng-if="info.nConflicts > 0" title="the current organization seems in conflict with {{info.nConflicts}} other(s)">new</span></a>
</li>
<li class="nav-item">
<a href="javascript:void(0)" class="nav-link" ng-class="{'active': currentTab == 4}" ng-click="gotoTab(4)">Note <span class="badge badge-danger ml-2" ng-if="info.note">*</span></a>
</li>
<li class="nav-item" ng-show="adminMode">
<a href="javascript:void(0)" class="nav-link" ng-class="{'active': currentTab == 5}" ng-click="gotoTab(5)">Journal</a>
</li>
</ul>
</div>
@ -35,16 +41,24 @@
<div class="card-body" ng-if="currentTab == 2 && org.status == 'approved'">
<org-details org="org" org-title="Current organization" show="default"></org-details>
<org-duplicates org-id="{{org.id}}" duplicates="duplicates" save-function="saveDuplicates()" show-buttons="1"></org-form-duplicates>
<org-duplicates org-id="{{org.id}}" duplicates="duplicates" save-function="saveDuplicates()" show-buttons="1"></org-duplicates>
</div>
<div class="card-body" ng-if="currentTab == 2 && org.status == 'suggested'">
<org-details org="org" org-title="Current organization" show="default"></org-details>
<org-duplicates org-id="{{org.id}}" duplicates="duplicates" readonly="1"></org-form-duplicates>
<org-duplicates org-id="{{org.id}}" duplicates="duplicates" readonly="1"></org-duplicates>
</div>
<div class="card-body" ng-if="adminMode && currentTab == 3 && (org.status == 'approved' || org.status == 'suggested')">
<org-conflicts org="org" conflicts="conflicts" show-buttons="1"></org-form-conflicts>
<org-conflicts org="org" conflicts="conflicts" show-buttons="1"></org-conflicts>
</div>
<div class="card-body" ng-if="currentTab == 4 && org.status">
<org-note org="org" note="note"></org-note>
</div>
<div class="card-body" ng-if="adminMode && currentTab == 5">
<org-journal org="org" logs="logs"></org-journal>
</div>
</div>

View File

@ -0,0 +1,21 @@
<table class="table table-sm table-striped">
<thead>
<tr class="d-flex">
<th class="col-2">date</th>
<th class="col-1">operation</th>
<th class="col-7">description</th>
<th class="col-2">performed by</th>
</tr>
</thead>
<tbody>
<tr ng-if="logs.length == 0" class="d-flex">
<td colspan="4" class="col-12">No registered events !!!</td>
</tr>
<tr ng-repeat="l in logs" class="d-flex">
<th class="text-monospace col-2">{{l.date| date:'yyyy-MM-dd @ HH:mm:ss'}}</th>
<td class="col-1"><span class="small">{{l.operation}}</span></td>
<td class="col-7">{{l.description}}</td>
<td class="col-2">{{l.email}}</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,14 @@
<form name="noteForm">
<fieldset>
<p ng-if="note.modifiedBy">
<b>Note updated at</b> {{note.modificationDate | date:'MMMM d, y HH:mm:ss'}} <b>by</b> {{note.modifiedBy}}
</p>
<div class="form-group">
<textarea class="form-control" rows="10" ng-model="note.note"></textarea>
</div>
</fieldset>
<fieldset>
<button type="submit" class="btn btn-primary" ng-click="save()">Save</button>
</fieldset>
</form>

View File

@ -21,9 +21,7 @@
<span ng-if="orgs.totalElements == 0"><b>Total elements:</b> 0</span>
</p>
<h4 ng-if="orgs.totalElements == 0" class="text-center">
No results
</h4>
<h4 ng-if="orgs.totalElements == 0" class="text-center">No results</h4>
<div ng-if="orgs.totalElements > 0">

View File

@ -336,6 +336,38 @@ orgsModule.directive('orgConflicts', function($http, $window, $location, $route,
}
});
orgsModule.directive('orgNote', function($http) {
return {
restrict: 'E',
scope: {
'org' : '=',
'note': '='
},
templateUrl: 'resources/html/parts/org_note.html',
link: function(scope, element, attrs, ctrl) {
scope.save = function() {
call_http_post($http, 'api/organizations/note', scope.note, function(res) {
alert("Note saved !!!");
scope.note = res.data;
});
}
}
}
});
orgsModule.directive('orgJournal', function($http) {
return {
restrict: 'E',
scope: {
'org' : '=',
'logs': '='
},
templateUrl: 'resources/html/parts/org_journal.html',
link: function(scope, element, attrs, ctrl) {}
}
});
orgsModule.config(function($routeProvider) {
$routeProvider
.when('/search', { templateUrl: 'resources/html/pages/search/search.html', controller: 'searchCtrl' })
@ -504,7 +536,15 @@ orgsModule.controller('showEditCtrl', function ($scope, $http, $routeParams, $ro
} else if (tab == 3) {
$scope.conflicts = [];
call_http_get($http, 'api/organizations/conflicts?id=' + $scope.orgId, function(res) { $scope.conflicts = res.data; });
} else if (tab == 4) {
$scope.note = {};
call_http_get($http, 'api/organizations/note?id=' + $scope.orgId, function(res) { $scope.note = res.data; });
} else if (tab == 5) {
$scope.logs = [];
call_http_get($http, 'api/organizations/journal?id=' + $scope.orgId, function(res) { $scope.logs = res.data; });
}
$scope.currentTab = tab;
}

View File

@ -188,6 +188,7 @@ fieldset > legend { font-size : 1.2rem !important; }
function call_http_get($http, url, onSuccess) {
showSpinner();
$http.get(url).then(function successCallback(res) {
hideSpinner();
if((typeof res.data) == 'string') {