Commit c54e1109 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Simplifica widgets fijos de vistas detalle

Separa la definición y configuración de widgets de detalle que son fijos
para algunas vistas de aquellos que son configurables mediante config
externa, simplificando y aligerando el manejo de las primeras.

Refactoriza y mantiene mismo funcionamiento, salvo por la vista de
detalle de activity, que aún no tiene disponible el mecanismo para
procesar la config externa y cargar los widgets que define el layout
(falla por el momento, tras los últimos cambios).
parent ec0f95a0
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ define([
	, 'app/designs/details/_AddWidgetSelector'
	, 'app/designs/details/_AddTitle'
	, 'dojo/_base/declare'
	, 'src/detail/_WidgetDefinition'
	, 'src/detail/_DetailWidgetDefinition'
], function(
	_Main
	, Controller
@@ -13,10 +13,10 @@ define([
	, _AddWidgetSelector
	, _AddTitle
	, declare
	, _WidgetDefinition
	, _DetailWidgetDefinition
) {

	return declare([Layout, Controller, _Main, _AddTitle, _AddWidgetSelector, _WidgetDefinition], {
	return declare([Layout, Controller, _Main, _AddTitle, _AddWidgetSelector, _DetailWidgetDefinition], {
		//	summary:
		//		Base común a todas las vistas de detalle.

@@ -32,11 +32,24 @@ define([
				}]);
			}

			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {
				info: this._getInfoConfig({
					template: this.templateInfo
				})
			this._infoPrepareDetailWidget();
		},

		_infoPrepareDetailWidget: function() {

			const configProps = {
				template: this.templateInfo,
				target: this.infoTarget || this.target,
				associatedIds: [this.ownChannel],
				shownOption: this.shownOptionInfo
			};

			const info = this._merge([this._getInfoConfig(configProps), {
				width: 3,
				height: 'fitContent'
			}]);

			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {info}]);
		},

		addTargetToArray: function(/*string*/ target) {
+30 −4
Original line number Diff line number Diff line
@@ -30,11 +30,37 @@ define([

			this.addTargetToArray(this.ancestorsTarget);

			this._administrativePrepareDetailWidgets();
		},

		_administrativePrepareDetailWidgets: function() {

			const commonConfigProps = {
				width: 3,
				height: 4
			};

			const organisationList = this._merge([this._getOrganisationsConfig({
				target: this.organisationTarget
			}), commonConfigProps]);

			const platformList = this._merge([this._getPlatformsConfig({
				target: this.platformTarget
			}), commonConfigProps]);

			const contactList = this._merge([this._getContactsConfig({
				target: this.contactTarget
			}), commonConfigProps]);

			const documentList = this._merge([this._getDocumentsConfig({
				target: this.documentTarget
			}), commonConfigProps]);

			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {
				organisationList: this._getOrganisationsConfig(),
				platformList: this._getPlatformsConfig(),
				contactList: this._getContactsConfig(),
				documentList: this._getDocumentsConfig()
				organisationList,
				platformList,
				contactList,
				documentList
			}]);
		},

+16 −4
Original line number Diff line number Diff line
@@ -14,12 +14,24 @@ define([

			this.inherited(arguments);

			let additionalConfig = this._getAdditionalDescendantListConfig();
			this._descendantListPrepareDetailWidget();
		},

		_descendantListPrepareDetailWidget: function() {

			const additionalConfig = this._merge([this._getAdditionalDescendantListConfig(), {
				target: this.descendantsTarget
			}]);

			const descendantList = this._merge([this._getActivitiesOrProjectsConfig(additionalConfig), {
				width: 3,
				height: 4
			}]);

			this.widgetConfigs = this._merge([{
			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {
				info: {},
				descendantList: this._getActivitiesOrProjectsConfig(additionalConfig)
			}, this.widgetConfigs || {}]);
				descendantList
			}]);
		},

		_clearModules: function() {
+18 −11
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/detail/_Detail'
	, 'src/redmicConfig'
	, 'templates/ActivityList'
], function(
	declare
	, lang
	, _Detail
	, redmicConfig
	, TemplateActivities
@@ -21,16 +19,25 @@ define([
			this.inherited(arguments);

			this.addTargetToArray(this.ancestorsTarget);
			//this.addTargetToArray(this.activitiesTargetBase);

			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {
				activityList: this._getActivitiesOrProjectsConfig({
			this._activityListPrepareDetailWidget();
		},

		_activityListPrepareDetailWidget: function() {

			const configProps = {
				title: 'activities',
				target: this.activitiesTargetBase,
				template: TemplateActivities,
				href: redmicConfig.viewPaths.activityDetails
				})
			};

			const activityList = this._merge([this._getActivitiesOrProjectsConfig(configProps), {
				width: 3,
				height: 4
			}]);

			this.widgetConfigs = this._merge([this.widgetConfigs || {}, {activityList}]);
		},

		_clearModules: function() {
+215 −0
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'src/component/base/_Module'
	, 'src/component/base/_Show'
	, 'src/component/base/_Store'
	, 'src/component/layout/templateDisplayer/TemplateDisplayer'
	, 'src/component/map/_ImportWkt'
	, 'src/component/map/LeafletImpl'
	, 'src/design/browser/_AddTotalBarComponent'
	, 'src/design/browser/_BrowserFullSizeDesignLayout'
	, 'src/redmicConfig'
	, 'src/util/Credentials'
	, 'templates/ContactSet'
	, 'templates/DocumentList'
	, 'templates/OrganisationSet'
	, 'templates/PlatformSet'
], function(
	declare
	, _Module
	, _Show
	, _Store
	, TemplateDisplayer
	, _ImportWkt
	, LeafletImpl
	, _AddTotalBarComponent
	, _BrowserFullSizeDesignLayout
	, redmicConfig
	, Credentials
	, TemplateContacts
	, TemplateDocuments
	, TemplateOrganisation
	, TemplatePlatform
) {

	return declare(null, {
		// summary:
		//   Métodos para obtener la configuración (definición y propiedades) de widgets básicos para vistas detalle.

		_getOrganisationsConfig: function(config) {

			const rowConfig = {
				buttonsConfig: {
					listButton: [{
						icon: 'fa-info-circle',
						btnId: 'details',
						title: this.i18n.info,
						href: redmicConfig.viewPaths.organisationDetails,
						pathToItem: 'organisation'
					}]
				}
			};

			return {
				type: declare([_Module, _Show, _Store, _BrowserFullSizeDesignLayout, _AddTotalBarComponent]),
				props: {
					title: 'organisations',
					target: config.target,
					browserConfig: {
						template: TemplateOrganisation,
						rowConfig
					}
				}
			};
		},

		_getPlatformsConfig: function(config) {

			const rowConfig = {
				buttonsConfig: {
					listButton: [{
						icon: 'fa-info-circle',
						btnId: 'details',
						title: this.i18n.info,
						href: redmicConfig.viewPaths.platformDetails,
						pathToItem: 'platform'
					}]
				}
			};

			return {
				type: declare([_Module, _Show, _Store, _BrowserFullSizeDesignLayout, _AddTotalBarComponent]),
				props: {
					title: 'platforms',
					target: config.target,
					browserConfig: {
						template: TemplatePlatform,
						rowConfig
					}
				}
			};
		},

		_getContactsConfig: function(config) {

			const rowConfig = {
				buttonsConfig: {
					listButton: [{
						icon: 'fa-info-circle',
						btnId: 'details',
						title: this.i18n.info,
						href: redmicConfig.viewPaths.contactDetails,
						pathToItem: 'contact'
					}]
				}
			};

			return {
				type: declare([_Module, _Show, _Store, _BrowserFullSizeDesignLayout, _AddTotalBarComponent]),
				props: {
					title: 'contacts',
					target: config.target,
					browserConfig: {
						template: TemplateContacts,
						rowConfig
					}
				}
			};
		},

		_getDocumentsConfig: function(config) {

			const rowConfig = {
				buttonsConfig: {
					listButton: [{
						icon: 'fa-info-circle',
						btnId: 'details',
						title: this.i18n.info,
						href: redmicConfig.viewPaths.bibliographyDetails
					}]
				}
			};

			return {
				type: declare([_Module, _Show, _Store, _BrowserFullSizeDesignLayout, _AddTotalBarComponent]),
				props: {
					title: 'documents',
					target: config.target,
					browserConfig: {
						template: TemplateDocuments,
						rowConfig
					}
				}
			};
		},

		_getActivitiesOrProjectsConfig: function(config) {

			const condition = function(item) {

				const accessibilityId = item?.accessibility?.id,
					browseableAccesibilities = [2], // libre
					accessibilityIsBrowseable = browseableAccesibilities.includes(accessibilityId);

				return accessibilityIsBrowseable || Credentials.userIsEditor();
			};

			const rowConfig = {
				buttonsConfig: {
					listButton: [{
						icon: 'fa-info-circle',
						btnId: 'details',
						title: this.i18n.info,
						href: config.href,
						condition
					}]
				}
			};

			return {
				type: declare([_Module, _Show, _Store, _BrowserFullSizeDesignLayout, _AddTotalBarComponent]),
				props: {
					title: config.title,
					target: config.target,
					browserConfig: {
						template: config.template,
						rowConfig
					}
				}
			};
		},

		_getInfoConfig: function(config) {

			return {
				type: TemplateDisplayer,
				props: {
					title: 'info',
					template: config.template,
					'class': 'containerDetails',
					classEmptyTemplate: 'contentListNoData',
					target: config.target,
					associatedIds: config.associatedIds,
					shownOption: config.shownOption
				}
			};
		},

		_getSpatialExtensionConfig: function(config) {

			return {
				type: declare([LeafletImpl, _ImportWkt]),
				props: {
					title: 'spatialExtension',
					omitContainerSizeCheck: true,
					maxZoom: 15,
					coordinatesViewer: false,
					navBar: false,
					miniMap: false,
					scaleBar: false,
					measureTools: false
				}
			};
		}
	});
});
Loading