Skip to content

Commit 7e83b2e

Browse files
Workflow / Editor board / Add search configuration to display draft, approved record or both (geonetwork#7477)
* Workflow / Editor board / Display draft instead of approved records. When using the workflow, if a published and approved record is edited, a working copy is created. Users have difficulties to find the corresponding working copies because the searches show the approved records with a link to the copies but does not search directly for working copies. This change propose to have: * the search app to search for records without draft and approved records * the editor board app to search for records without draft and drafts. In the editor board, sorting by last updates will properly list last updated draft records and will facilitate editing works. The draft will provide a link to the corresponding approved records (instead of approved record linking to the working copy). It also makes more sense to list draft here as user clicking edit button will edit the draft record. * Update web-ui/src/main/resources/catalog/components/search/resultsview/partials/viewtemplates/editor.html Co-authored-by: joachimnielandt <[email protected]> * Update web-ui/src/main/resources/catalog/components/search/resultsview/partials/viewtemplates/editor.html Co-authored-by: joachimnielandt <[email protected]> * Update web-ui/src/main/resources/catalog/components/utility/partials/draftvalidationwidget.html Co-authored-by: joachimnielandt <[email protected]> * Workflow / Editor board / Configure which type of record to promote in search - draft, approved or both. * Workflow / Editor board / Configure which type of record to promote in search / Admin config. * Workflow / Editor board / Prettier. * Workflow / Editor board / Display approved status in badge. * Workflow / Editor board / Configuration / Improve description. --------- Co-authored-by: joachimnielandt <[email protected]>
1 parent 5f86440 commit 7e83b2e

File tree

10 files changed

+53
-16
lines changed

10 files changed

+53
-16
lines changed

services/src/main/java/org/fao/geonet/api/es/EsHTTPProxy.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ private void addFilterToQuery(ServiceContext context,
463463
// Build filter node
464464
String esFilter = buildQueryFilter(context,
465465
"",
466-
esQuery.toString().contains("\"draft\":"));
466+
esQuery.toString().contains("\"draft\":")
467+
|| esQuery.toString().contains("+draft:")
468+
|| esQuery.toString().contains("-draft:"));
467469
JsonNode nodeFilter = objectMapper.readTree(esFilter);
468470

469471
JsonNode queryNode = esQuery.get("query");

web-ui/src/main/resources/catalog/components/admin/uiconfig/partials/uiconfig.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ <h2>{{('ui-mod-' + m) | translate}}</h2>
202202

203203
<div
204204
class="row"
205-
data-ng-switch-when="autocompleteConfig|moreLikeThisConfig|facetConfig|relatedFacetConfig|filters|scoreConfig|queryBaseOptions|collectionTableConfig|distributionConfig|topCustomMenu|wpsSource"
205+
data-ng-switch-when="autocompleteConfig|moreLikeThisConfig|facetConfig|relatedFacetConfig|filters|scoreConfig|queryBaseOptions|collectionTableConfig|distributionConfig|topCustomMenu|wpsSource|workflowSearchRecordTypes"
206206
data-ng-switch-when-separator="|"
207207
>
208208
<div class="col-lg-5 gn-nopadding-left">

web-ui/src/main/resources/catalog/components/search/resultsview/partials/viewtemplates/editor.html

+10-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<a
2626
href=""
2727
data-ng-show="md.isTemplate != 's'"
28-
data-ng-href="catalog.search#/{{(md.draft == 'y')?'metadraf':'metadata'}}/{{md.uuid}}"
28+
data-ng-href="catalog.search#/{{(md.draft == 'y') ? 'metadraf' : 'metadata'}}/{{md.uuid}}"
2929
title="{{md.resourceAbstract}}"
3030
class="gn-break"
3131
>
@@ -53,8 +53,14 @@
5353
class="text-muted gn-status"
5454
data-ng-class="{'text-success': md.mdStatus == 2, 'text-warning': md.mdStatus == 4}"
5555
data-ng-if="md.mdStatus < 50 && isMdWorkflowEnable"
56-
>{{::md.statusWorkflow | getStatusLabel}}</small
5756
>
57+
<span data-ng-if="md.draft === 'e' || md.draft === 'n'"
58+
>{{::md.statusWorkflow | getStatusLabel}}</span
59+
>
60+
<span data-ng-if="md.draft === 'y'"
61+
>{{::'status-' + md.mdStatus | translate}}</span
62+
>
63+
</small>
5864

5965
<small
6066
class="text-muted gn-status"
@@ -68,8 +74,8 @@
6874
</div>
6975
</div>
7076
<gn-draft-validation-widget
71-
data-ng-if="md.draft == 'e'"
72-
metadata="md"
77+
data-ng-if="md.draft == 'e' || md.draft == 'y'"
78+
data-metadata="md"
7379
></gn-draft-validation-widget>
7480
</div>
7581
<div class="col-lg-4 col-md-4 gn-nopadding-right">

web-ui/src/main/resources/catalog/components/utility/DraftValidationWidget.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,37 @@
3737
metadata: "="
3838
},
3939
link: function (scope) {
40+
if (!scope.metadata) {
41+
return;
42+
}
43+
scope.type = scope.metadata.draft === "e" ? "y" : "e";
4044
var query = {
4145
_source: {
4246
includes: ["id", "uuid", "draft", "isTemplate", "valid"]
4347
},
44-
size: 10,
48+
size: 1,
4549
query: {
4650
bool: {
4751
must: [
4852
{ terms: { uuid: [scope.metadata.uuid] } },
4953
{ terms: { isTemplate: ["y", "n"] } },
50-
{ terms: { draft: ["y"] } }
54+
{ terms: { draft: [scope.type] } }
5155
]
5256
}
5357
}
5458
};
5559

5660
$http.post("../api/search/records/_search", query).then(function (r) {
5761
r.data.hits.hits.forEach(function (r) {
58-
scope.draft = new Metadata(r);
62+
scope.record = new Metadata(r);
63+
scope.recordIsDraft = scope.record.draft === "y";
64+
scope.label = scope.recordIsDraft ? "seeDraft" : "seeNoDraft";
65+
scope.title = scope.recordIsDraft ? "draft" : "approvedRecord";
5966
});
6067
});
6168
},
6269
templateUrl:
63-
"../../catalog/components/utility/" + "partials/draftvalidationwidget.html"
70+
"../../catalog/components/utility/partials/draftvalidationwidget.html"
6471
};
6572
}
6673
]);

web-ui/src/main/resources/catalog/components/utility/UtilityDirective.js

+3
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,9 @@
22452245
"$translate",
22462246
function ($translate) {
22472247
return function (workflowStatus) {
2248+
if (!workflowStatus) {
2249+
return;
2250+
}
22482251
var split = workflowStatus.split("-");
22492252
// the status of the record
22502253
var metadataStatus = $translate.instant("status-" + split[0]);
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
<a
2+
data-ng-show="record"
23
href=""
3-
data-ng-href="catalog.search#/{{(draft.draft == 'y')?'metadraf':'metadata'}}/{{metadata.uuid}}"
4+
data-ng-href="catalog.search#/{{recordIsDraft ? 'metadraf' : 'metadata'}}/{{record.uuid}}"
45
class="see-draft-pill"
56
>
67
<small>
78
<small
8-
class="valid-status{{draft.valid}} md-type-{{draft.isTemplate}}"
9-
title="{{(('draft') | translate)}}: {{(('validStatus-' + draft.valid) | translate)}}"
10-
ng-switch="draft.isTemplate"
9+
class="valid-status{{record.valid}} md-type-{{record.isTemplate}}"
10+
title="{{(title | translate)}}: {{(('validStatus-' + record.valid) | translate)}}"
11+
ng-switch="record.isTemplate"
1112
>
1213
<i class="fa fa-fw fa-file" ng-switch-when="y" />
13-
<i class="fa fa-fw fa-pencil" ng-switch-when="n" />
14+
<i
15+
class="fa fa-fw"
16+
data-ng-class="{'fa-pencil':recordIsDraft, 'fa-file-text-o':!recordIsDraft}"
17+
ng-switch-when="n"
18+
/>
1419
<i class="fa fa-fw fa-bookmark" ng-switch-when="s" />
1520
<i class="fa fa-fw fa-bookmark-o" ng-switch-when="t" />
1621
<i class="fa fa-fw fa-question" ng-switch-default />
1722
</small>
18-
<label title="{{'seeDraft' | translate}}">{{(('draft') | translate)}}</label>
23+
<label title="{{label | translate}}">{{title | translate}}</label>
1924
</small>
2025
</a>

web-ui/src/main/resources/catalog/js/CatController.js

+2
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@
948948
createPageTpl: "../../catalog/templates/editor/new-metadata-horizontal.html",
949949
editorIndentType: "",
950950
allowRemoteRecordLink: true,
951+
workflowSearchRecordTypes: ["n", "e"],
951952
facetConfig: {
952953
resourceType: {
953954
terms: {
@@ -1287,6 +1288,7 @@
12871288
"distributionConfig",
12881289
"collectionTableConfig",
12891290
"queryBaseOptions",
1291+
"workflowSearchRecordTypes",
12901292
"workflowAssistApps"
12911293
],
12921294
current: null,

web-ui/src/main/resources/catalog/js/edit/EditorBoardController.js

+9
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
$scope.isFilterTagsDisplayed =
7272
gnGlobalSettings.gnCfg.mods.editor.isFilterTagsDisplayed;
7373
$scope.modelOptions = angular.copy(gnGlobalSettings.modelOptions);
74+
7475
$scope.defaultSearchObj = {
7576
permalink: true,
7677
sortbyValues: gnSearchSettings.sortbyValues,
@@ -82,6 +83,10 @@
8283
sortBy: "dateStamp",
8384
sortOrder: "desc",
8485
isTemplate: ["y", "n"],
86+
draft: gnGlobalSettings.gnCfg.mods.editor.workflowSearchRecordTypes || [
87+
"n",
88+
"e"
89+
],
8590
resultType: $scope.facetsSummaryType,
8691
from: 1,
8792
to: 20
@@ -90,6 +95,10 @@
9095
sortBy: "dateStamp",
9196
sortOrder: "desc",
9297
isTemplate: ["y", "n"],
98+
draft: gnGlobalSettings.gnCfg.mods.editor.workflowSearchRecordTypes || [
99+
"n",
100+
"e"
101+
],
93102
resultType: $scope.facetsSummaryType,
94103
from: 1,
95104
to: 20

web-ui/src/main/resources/catalog/locales/en-admin.json

+2
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,8 @@
10781078
"git.build.time": "Timestamp of the build",
10791079
"testClientConfig": "Test client configuration",
10801080
"resetDefaultConfig": "Reset configuration",
1081+
"ui-workflowSearchRecordTypes": "Workflow / Search / Display draft, approved or both",
1082+
"ui-workflowSearchRecordTypes-help": "Define what to display in <strong>editor board search panel</strong>:<ul><li>[\"n\", \"e\"] display approved version (default)</li><li>[\"n\", \"y\"] will show draft</li><li>[\"n\", \"e\", \"y\"] will show both draft and approved</li></ul>. \"n\" is for record without draft, \"e\" for approved record and \"y\" for draft record.",
10811083
"ui-mod-header": "Top toolbar",
10821084
"ui-mod-footer": "Footer",
10831085
"ui-mod-cookieWarning": "Cookie warning",

web-ui/src/main/resources/catalog/locales/en-core.json

+1
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@
551551
"cancelWorkingCopy": "Cancel working copy",
552552
"deleteWorkingCopyRecordConfirm": "Do you really want to remove the working copy '{{resourceTitle}}'?",
553553
"workingCopy": "Working copy",
554+
"approvedRecord": "Approved record",
554555
"onTheWeb": "More online information",
555556
"pdfReportTocTitle": "Contents",
556557
"metadataValidated": "Metadata validated.",

0 commit comments

Comments
 (0)