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

Actualiza módulos, remodela estadísticas

parent 0e07aac0
Loading
Loading
Loading
Loading
+132 −22
Original line number Diff line number Diff line
@@ -4,20 +4,24 @@ define([
	, 'dojo/_base/lang'
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Show'
	, 'redmic/modules/base/_ShowInTooltip'
	, 'redmic/modules/base/_Store'
	, 'redmic/modules/browser/_ButtonsInRow'
	, 'redmic/modules/browser/ListImpl'
	, 'templates/AdministrativeStatisticsList'
	, 'redmic/modules/layout/dataDisplayer/DataDisplayer'
	, 'templates/StatisticsList'
], function(
	redmicConfig
	, declare
	, lang
	, _Module
	, _Show
	, _ShowInTooltip
	, _Store
	, _ButtonsInRow
	, ListImpl
	, ListTemplate
	, DataDisplayer
	, StatisticsListTemplate
) {

	return declare([_Module, _Show, _Store], {
@@ -30,6 +34,7 @@ define([
				target: redmicConfig.services.administrativeStatistics,
				_browserTarget: 'browserStatistics',
				'class': 'statsPanel',
				infoTooltipClass: 'inputInfoTooltipContent',
				_titleRightButtonsList: []
			};

@@ -41,14 +46,20 @@ define([
			this.browserConfig = this._merge([{
				parentChannel: this.getChannel(),
				target: this._browserTarget,
				template: ListTemplate,
				template: StatisticsListTemplate,
				rowConfig: {
					buttonsConfig: {
						listButton: [{
							icon: 'fa-info-circle',
							btnId: 'info',
							title: 'infoButtonTitle',
							returnItem: true,
							node: true
						},{
							icon: 'fa-arrow-right',
							btnId: 'details',
							title: this.i18n.info,
							href: '/admin/{href}'
							title: 'catalog',
							href: '/catalog/{href}-catalog'
						}]
					}
				}
@@ -56,6 +67,21 @@ define([

			var browserDefinition = declare([ListImpl, _ButtonsInRow]);
			this.browser = new browserDefinition(this.browserConfig);

			this._infoDefinition = declare(DataDisplayer).extend(_ShowInTooltip);
		},

		_defineSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel: this.browser.getChannel('BUTTON_EVENT'),
				callback: '_subBrowserButtonEvent'
			});
		},

		_subBrowserButtonEvent: function(res) {

			this._showStatsInfo(res.item, res.iconNode);
		},

		_afterShow: function() {
@@ -81,7 +107,15 @@ define([
			};
		},

		_dataAvailable: function(res, resWrapper) {
		_addStats: function(data) {

			this._emitEvt('INJECT_ITEM', {
				data: data,
				target: this._browserTarget
			});
		},

		_dataAvailable: function(res) {

			var data = res.data;

@@ -89,29 +123,105 @@ define([
				return;
			}

			var specificStatsData = [{
				attachedKey: 'activity',
				independentKey: 'activityOutProject'
			},{
				attachedKey: 'project',
				independentKey: 'projectOutProgram'
			},{
				attachedKey: 'program'
			}];

			var id = 1;

			for (var item in data) {
				var result = {};
				result.data = data[item];
				result.name = item;
				result.id = id;

				if ('activityOutProject' === item) {
					result.href = 'activity';
				} else if ('projectOutProgram' === item) {
					result.href = 'project';
				} else {
					result.href = item;
			for (var i in specificStatsData) {
				var specificStatsItem = specificStatsData[i],
					attachedKey = specificStatsItem.attachedKey,
					independentKey = specificStatsItem.independentKey,
					specificData = this._extractSpecificStats(data, attachedKey, independentKey);

				this._addStats({
					id: id,
					name: attachedKey,
					stats: specificData,
					href: attachedKey === 'activity' ? 'activities': attachedKey // TODO ruta incorrecta de vista
				});

				id++;
			}

				this._emitEvt('INJECT_ITEM', {
					data: result,
					target: this._browserTarget
			for (var item in data) {
				this._addStats({
					id: id,
					name: item,
					stats: data[item],
					href: item
				});

				id++;
			}
		},

		_extractSpecificStats: function(data, attachedKey, independentKey) {

			var sourceStats = data[attachedKey],
				sourceIndependentStats = independentKey ? data[independentKey] : null,
				attachedTotal = sourceStats.open + sourceStats.close;

			var stats = {
				attachedTotal: attachedTotal,
				attachedOpen: sourceStats.open,
				attachedClosed: sourceStats.close
			};

			if (independentKey) {
				var independentTotal = sourceIndependentStats.open + sourceIndependentStats.close;

				stats.independentTotal = independentTotal;
				stats.independentOpen = sourceIndependentStats.open;
				stats.independentClosed = sourceIndependentStats.close;

				stats.total = attachedTotal + independentTotal;
				stats.totalOpen = sourceStats.open + sourceIndependentStats.open;
				stats.totalClosed = sourceStats.close + sourceIndependentStats.close;

				delete data[independentKey];
			} else {
				stats.total = attachedTotal;
				stats.totalOpen = sourceStats.open;
				stats.totalClosed = sourceStats.close;
			}

			delete data[attachedKey];

			return stats;
		},

		_showStatsInfo: function(item, sourceNode) {

			if (!item) {
				return;
			}

			var info = item.name;

			if (!info || !info.length) {
				return;
			}

			var infoKey = info + 'MoreInfo',
				infoValue = this.i18n[infoKey] || infoKey;

			this._infoInstance = new this._infoDefinition({
				parentChannel: this.getChannel(),
				data: infoValue,
				'class': this.infoTooltipClass
			});

			this._publish(this._infoInstance.getChannel('SHOW'), {
				node: sourceNode
			});
		}
	});
});
+10 −3
Original line number Diff line number Diff line
@@ -250,8 +250,8 @@ define({
	, "recording-types": "Tipos de grabación"

	, "closed": "Concluido"
	, "activityOutProjects": "Actividades fuera de proyectos"
	, "projectOutPrograms": "Proyectos fuera de programas"
	, "attached": "Asociado"
	, "independent": "Independiente"

	, "precision": "Precisión"
	, "bathymetry": "Batimetría"
@@ -1247,6 +1247,13 @@ define({
	, "documentFilterInfo": "Las actividades pueden contener información en forma de documentos, como memorias de proyecto, artículos de revista, publicaciones científicas... Utiliza este filtro para encontrar actividades relacionadas con algún documento de la biblioteca."
	, "platformFilterInfo": "Las labores desempeñadas en el desarrollo de una actividad pueden tener lugar en una o varias plataformas. Utiliza este filtro para encontrar actividades que guardan relación con una plataforma concreta."

	, "activityMoreInfo": "La actividad es el elemento básico para organizar la información. Recoge los metadatos que definen al conjunto de datos (dataset) marinos generados en dicha actividad. Las actividades pueden ser independientes o pertenecer a un proyecto. Atendiendo a su fecha de inicio y finalización, pueden estar en curso o concluidas."
	, "projectMoreInfo": "Un proyecto es una colección de actividades que persiguen un mismo fin. Usualmente son desarrollados por una única organización. Los proyectos pueden ser independientes o pertenecer a un programa. Atendiendo a su fecha de inicio y finalización, pueden estar en curso o concluidos."
	, "programMoreInfo": "Un programa es una agrupación de proyectos que guardan relación entre sí. Suelen tener una duración prolongada y es común que participen varias organizaciones con diferentes roles en ellos. Atendiendo a su fecha de inicio y finalización, pueden estar en curso o concluidos."
	, "documentMoreInfo": "Los documentos contienen información de cualquier tipo, desde bibliografía marina hasta contenido técnico relacionado con la obtención de datos."
	, "organisationMoreInfo": "Las organizaciones son entidades que participan en una actividad con un rol establecido. Pueden ser de carácter público, privado o profesionales autónomos."
	, "platformMoreInfo": "Una plataforma es cualquier instalación o artefacto, ya sea fijo o móvil, desde donde se opera para la obtención de datos, o que porta los sensores o aparatos de muestreo."

	// Para capas que no se pueden cambiar las keys
	, "descript_1": "Descripción"
	, "descriptio": "Descripción"
+10 −3
Original line number Diff line number Diff line
@@ -250,8 +250,8 @@ define({
		, "recording-types": "Recording types"

		, "closed": "Concluded"
		, "activityOutProjects": "Activities out of projects"
		, "projectOutPrograms": "Projects out of programs"
		, "attached": "Attached"
		, "independent": "Independent"

		, "precision": "Precision"
		, "bathymetry": "Bathymetry"
@@ -559,7 +559,7 @@ define({
		, "contactRole": "Contact role"
		, "organisationRole": "Organisation role"
		, "qualityControl": "Quality control"
		, "opened": "Alive"
		, "opened": "In progress"
		, "unit": "Unit"
		, "units": "Parameter unit"
		, "condition": "Attribute definition"
@@ -1251,6 +1251,13 @@ define({
		, "documentFilterInfo": "Activities can contain information in the form of documents, such as project reports, magazine articles, scientific publications... Use this filter to find activities related to a library document."
		, "platformFilterInfo": "The tasks performed in the development of an activity can take place on one or more platforms. Use this filter to find activities that are related to a specific platform."

		, "activityMoreInfo": "Activity is the basic element to organize information. It includes the metadata which defines the marine dataset generated in the activity. Activities can be independent or belong to a project. Based on their start and end date, they may be in progress or concluded."
		, "projectMoreInfo": "A project is a collection of activities that pursue the same goal. They are usually developed by a single organisation. Projects can be independent or belong to a program. Based on their start and end date, they may be in progress or concluded."
		, "programMoreInfo": "A program is a grouping of projects that are related to each other. They tend to last for a long time and commonly are participated by several organisations with different roles in them. Based on their start and end date, they may be in progress or concluded."
		, "documentMoreInfo": "Documents contain information of any kind, from marine bibliography to technical content related to data collection."
		, "organisationMoreInfo": "Organizations are entities that participate in an activity with an established role. They can be public, private or self-employed professionals."
		, "platformMoreInfo": "A platform is any installation or device, whether fixed or mobile, from where someone operates to obtain data, or which carry sensors or sampling devices."

		//Para capas que no se pueden cambiar las keys
		, "descript_1": "Description"
		, "descriptio": "Description"
Compare 0d657b20 to 4bb3d190
Original line number Diff line number Diff line
Subproject commit 0d657b20d6eac4cd6724a09c8ca62b1648728ae9
Subproject commit 4bb3d1905db0e340f62ae4131db9600490d9e0dd
Compare a83efed6 to b6688975
Original line number Diff line number Diff line
Subproject commit a83efed69d0a7085580ebf38c427101d77f27506
Subproject commit b66889759d633f0cd9d0b095f2abc172670a9222