diff --git a/src/List/listValueRenderers.js b/src/List/listValueRenderers.js
index 5c5eb742f..3677afd6e 100644
--- a/src/List/listValueRenderers.js
+++ b/src/List/listValueRenderers.js
@@ -31,3 +31,11 @@ addValueRenderer(
({ columnName, valueType }) => columnName === 'formType' && valueType === 'CONSTANT',
renderNothingWhenValueIsNotAString(({ value }) => ({value.toLowerCase()}))
);
+
+addValueRenderer(
+ ({ columnName, valueType, value }) => {
+ return columnName === 'icon' && valueType === 'URL' && value.endsWith('/icon')
+ },
+ ({ value }) =>
+)
+
diff --git a/src/config/custom-models/icon/IconModelDefinition.js b/src/config/custom-models/icon/IconModelDefinition.js
index 1d00466ee..2b42aebb5 100644
--- a/src/config/custom-models/icon/IconModelDefinition.js
+++ b/src/config/custom-models/icon/IconModelDefinition.js
@@ -66,14 +66,16 @@ export default class IconModelDefinition extends ModelDefinition {
name: iconData.key,
displayName: iconData.key,
id: iconData.key,
+ user: iconData.createdBy,
+ icon: iconData.href
});
}
get(id) {
// id is actually key here
console.log('get', id);
- return this.api.get(`icons/${id}`).then((icon) => this.iconToModel(icon));
- }
+ return this.api.get(`icons/${id}`).then(icon => this.iconToModel(icon));
+ }
list() {
console.log('icon list!');
@@ -94,7 +96,9 @@ export default class IconModelDefinition extends ModelDefinition {
};
const params = {
- fields: ':all',
+ fields:
+ 'key,description,custom,created,lastUpdated,createdBy[id,displayName,name],fileResource,href',
+ type: 'custom',
search: queryString || '',
};
@@ -111,12 +115,6 @@ export default class IconModelDefinition extends ModelDefinition {
response.icons,
response.pager
);
- console.log({ collection });
- // Array.from(collection.valuesContainerMap).forEach(m => {
- // m.value.dataValues.id = m.value.key
- // m.value.id = m.value.key
- // })
- // Array.from(collection).map(m => m.id = m.key)
return collection;
});
console.log(res);
diff --git a/src/config/custom-models/icon/iconSchemaDefinition.js b/src/config/custom-models/icon/iconSchemaDefinition.js
index 5ef42b216..792200f69 100644
--- a/src/config/custom-models/icon/iconSchemaDefinition.js
+++ b/src/config/custom-models/icon/iconSchemaDefinition.js
@@ -1,3 +1,17 @@
+/* Icon does not have a schema, so we create a synthetic one
+It also does not have an id (it has user-defined key instead).
+This presents some challenges because a lot of the model-code is tied
+to them having an ID. So we add a "synthetic"-ID field
+
+Some other fields are also "synthetic" (eg. does not exist at all on the Icon object)
+
+ - Access - this is calculated in the IconModelDefinition
+ - Name === key
+ - Displayname === key
+ - Icon === href . This is mostly because "href"-field is translated to "API URL" by default
+ - User === createdBy
+*/
+
const iconSchemaDefinition = {
klass: 'org.hisp.dhis.icon',
shareable: false,
@@ -12,15 +26,15 @@ const iconSchemaDefinition = {
authorities: [
{
type: 'CREATE_PUBLIC',
- authorities: ['F_SYSTEM_SETTING', 'F_LOCALE_ADD'],
+ authorities: ['M_dhis-web-maintenance'],
},
{
type: 'CREATE_PRIVATE',
- authorities: ['F_SYSTEM_SETTING', 'F_LOCALE_ADD'],
+ authorities: ['M_dhis-web-maintenance'],
},
{
type: 'DELETE',
- authorities: ['F_SYSTEM_SETTING'],
+ authorities: ['M_dhis-web-maintenance'],
},
],
properties: [
@@ -142,10 +156,10 @@ const iconSchemaDefinition = {
propertyTransformer: false,
},
{
- klass: 'java.util.List',
+ klass: 'java.util.Set',
propertyType: 'COLLECTION',
- itemKlass: 'org.hisp.dhis.translation.Translation',
- itemPropertyType: 'COMPLEX',
+ itemKlass: 'java.lang.String',
+ itemPropertyType: 'TEXT',
name: 'keyword',
fieldName: 'keywords',
persisted: false,
@@ -211,6 +225,38 @@ const iconSchemaDefinition = {
},
propertyTransformer: false,
},
+ {
+ klass: 'java.lang.String',
+ propertyType: 'URL',
+ name: 'icon',
+ fieldName: 'href',
+ persisted: false,
+ attribute: true,
+ simple: true,
+ collection: false,
+ ordered: false,
+ owner: false,
+ identifiableObject: false,
+ nameableObject: false,
+ embeddedObject: false,
+ analyticalObject: false,
+ readable: true,
+ writable: true,
+ unique: false,
+ required: false,
+ max: 1.7976931348623157e308,
+ min: 0,
+ manyToMany: false,
+ oneToOne: false,
+ manyToOne: false,
+ oneToMany: false,
+ translatable: false,
+ gistPreferences: {
+ included: 'AUTO',
+ transformation: 'AUTO',
+ },
+ propertyTransformer: false,
+ },
{
fieldName: 'created',
description: 'The date this object was created.',
@@ -235,6 +281,40 @@ const iconSchemaDefinition = {
persisted: true,
manyToOne: false,
},
+ {
+ klass: 'org.hisp.dhis.user.User',
+ propertyType: 'REFERENCE',
+ name: 'user',
+ fieldName: 'user',
+ persisted: false,
+ namespace: 'http://dhis2.org/schema/dxf/2.0',
+ attribute: false,
+ simple: false,
+ collection: false,
+ ordered: false,
+ owner: false,
+ identifiableObject: true,
+ nameableObject: false,
+ embeddedObject: false,
+ analyticalObject: false,
+ readable: true,
+ writable: true,
+ unique: false,
+ required: false,
+ manyToMany: false,
+ oneToOne: false,
+ manyToOne: false,
+ oneToMany: false,
+ href: 'https://debug.dhis2.org/dev/api/schemas/user',
+ relativeApiEndpoint: '/users',
+ apiEndpoint: 'https://debug.dhis2.org/dev/api/users',
+ translatable: false,
+ gistPreferences: {
+ included: 'AUTO',
+ transformation: 'AUTO',
+ },
+ propertyTransformer: true,
+ },
{
fieldName: 'lastUpdated',
description: 'The date the object was last updated.',
diff --git a/src/config/disabled-on-edit/icon.js b/src/config/disabled-on-edit/icon.js
new file mode 100644
index 000000000..3d773fd3d
--- /dev/null
+++ b/src/config/disabled-on-edit/icon.js
@@ -0,0 +1,3 @@
+export default [
+ 'key',
+];
diff --git a/src/config/disabled-on-edit/index.js b/src/config/disabled-on-edit/index.js
index 594e290a5..b5a48c268 100644
--- a/src/config/disabled-on-edit/index.js
+++ b/src/config/disabled-on-edit/index.js
@@ -7,6 +7,7 @@ import optionSet from './optionSet';
import programRule from './programRule';
import optionGroup from './optionGroup';
import optionGroupSet from './optionGroupSet';
+import icon from './icon.js'
const disabledByType = {
category,
@@ -14,6 +15,7 @@ const disabledByType = {
categoryOptionCombo,
categoryOptionGroup,
categoryOptionGroupSet,
+ icon,
optionSet,
programRule,
optionGroup,
diff --git a/src/config/field-config/field-order.js b/src/config/field-config/field-order.js
index 73e42100f..628930032 100644
--- a/src/config/field-config/field-order.js
+++ b/src/config/field-config/field-order.js
@@ -517,6 +517,12 @@ const fieldOrderByName = new Map([
'type',
'sqlQuery',
]],
+ ['icon', [
+ 'key',
+ 'description',
+ 'fileResource',
+ 'keywords',
+ ]],
]);
export default {
diff --git a/src/config/maintenance-models.js b/src/config/maintenance-models.js
index 6d70bfad9..eaaf0bc4d 100644
--- a/src/config/maintenance-models.js
+++ b/src/config/maintenance-models.js
@@ -228,9 +228,8 @@ const typeDetails = {
},
icon: {
columns: [
- 'displayName',
'key',
- 'href'
+ 'icon'
],
},
sqlView: {
diff --git a/src/i18n/i18n_module_en.properties b/src/i18n/i18n_module_en.properties
index fb3ca7249..f16483a32 100644
--- a/src/i18n/i18n_module_en.properties
+++ b/src/i18n/i18n_module_en.properties
@@ -2186,6 +2186,9 @@ icon_search=Search for icons
upload_icon=Upload icon
choose_file_to_upload=Choose file to upload
icons_custom=Custom
+key=Key
+keywords=Keywords
+icon_management=Icon management
differs_from_program=Differs from program
apply_to_selected_stages=Apply to selected stages