From 132cafa9f2372e77d632b4a47ef0c885bb08a23a Mon Sep 17 00:00:00 2001
From: esikkala <esko.ikkala@aalto.fi>
Date: Fri, 26 Apr 2019 07:30:41 +0300
Subject: [PATCH] Add manuscript owner facet

---
 src/client/reducers/manuscripts.js            |  2 +-
 src/client/reducers/manuscriptsFacets.js      | 17 +++++++++++++++++
 src/server/sparql/FacetConfigs.js             |  1 +
 src/server/sparql/SparqlQueriesManuscripts.js | 17 +++++++++--------
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/client/reducers/manuscripts.js b/src/client/reducers/manuscripts.js
index 482f8e6d..239e03c0 100644
--- a/src/client/reducers/manuscripts.js
+++ b/src/client/reducers/manuscripts.js
@@ -131,7 +131,7 @@ export const INITIAL_STATE = {
       valueType: 'owner',
       makeLink: true,
       sortValues: true,
-      numberedList: true,
+      numberedList: false,
       minWidth: 250
     },
     {
diff --git a/src/client/reducers/manuscriptsFacets.js b/src/client/reducers/manuscriptsFacets.js
index c74152b2..47003a85 100644
--- a/src/client/reducers/manuscriptsFacets.js
+++ b/src/client/reducers/manuscriptsFacets.js
@@ -67,6 +67,23 @@ export const INITIAL_STATE = {
       filterType: 'uriFilter',
       uriFilter: null
     },
+    owner: {
+      id: 'owner',
+      label: 'Owner',
+      // predicate: defined in backend
+      distinctValueCount: 0,
+      values: [],
+      flatValues: [],
+      sortBy: 'instanceCount',
+      sortDirection: 'desc',
+      sortButton: true,
+      spatialFilterButton: false,
+      isFetching: false,
+      searchField: true,
+      containerClass: 'ten',
+      filterType: 'uriFilter',
+      uriFilter: null
+    },
     // language: {
     //   id: 'language',
     //   label: 'Language',
diff --git a/src/server/sparql/FacetConfigs.js b/src/server/sparql/FacetConfigs.js
index 9658b628..fd5c5aed 100644
--- a/src/server/sparql/FacetConfigs.js
+++ b/src/server/sparql/FacetConfigs.js
@@ -63,6 +63,7 @@ export const facetConfigs = {
       facetValueFilter: '',
       label: 'Owner',
       labelPath: 'crm:P51_has_former_or_current_owner/skos:prefLabel',
+      predicate: 'crm:P51_has_former_or_current_owner',
       type: 'list',
     },
   },
diff --git a/src/server/sparql/SparqlQueriesManuscripts.js b/src/server/sparql/SparqlQueriesManuscripts.js
index 9f5d9191..abc61244 100644
--- a/src/server/sparql/SparqlQueriesManuscripts.js
+++ b/src/server/sparql/SparqlQueriesManuscripts.js
@@ -37,14 +37,15 @@ export const manuscriptProperties = `
   {
     ?id crm:P51_has_former_or_current_owner ?owner__id .
     ?owner__id skos:prefLabel ?owner__prefLabel .
-    OPTIONAL { ?owner__id mmm-schema:data_provider_url ?owner__dataProviderUrl }
-    OPTIONAL {
-      [] rdf:subject ?id ;
-        rdf:predicate crm:P51_has_former_or_current_owner ;
-        rdf:object ?owner__id ;
-        mmm-schema:order ?order .
-      BIND(xsd:integer(?order) + 1 AS ?owner__order)
-    }
+    BIND (?owner__id AS ?owner__dataProviderUrl)
+    #OPTIONAL { ?owner__id mmm-schema:data_provider_url ?owner__dataProviderUrl }
+    #OPTIONAL {
+    #  [] rdf:subject ?id ;
+    #    rdf:predicate crm:P51_has_former_or_current_owner ;
+    #    rdf:object ?owner__id ;
+    #    mmm-schema:order ?order .
+    #  BIND(xsd:integer(?order) + 1 AS ?owner__order)
+    #}
   }
   UNION
   {
-- 
GitLab