Commit 3883d1ef authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Elimina extensión y módulo en desuso

parent 1aff0646
Loading
Loading
Loading
Loading
+0 −91
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/aspect"
	, "dojo/query"
	, "redmic/modules/layout/details/HandleBarsTemplateImpl"
], function(
	declare
	, lang
	, aspect
	, query
	, HandleBarsTemplateImpl
){
	return declare(null, {
		//	summary:
		//		Extensión para las vistas con detalles desplegables.

		constructor: function(args){

			aspect.after(this, "_initialize", lang.hitch(this, this._initializeDetailsDropdown));
			aspect.after(this, "_defineSubscriptions", lang.hitch(this, this._defineDetailsDropdownSubscriptions));
		},

		_defineDetailsDropdownSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel : this._buildChannel(this.selectorChannel, this.browser.actions.SELECTED),
				callback: "_subItemSelected"
			});
		},

		_initializeDetailsDropdown: function() {

			var detailsConfig = {
				parentChannel: this.getChannel(),
				target: this.target,
				idProperty: this.idProperty,
				i18n: this.i18n,
				template: this.detailsTemplate
			};

			lang.mixin(detailsConfig, this.detailsConfig);

			this.details = new HandleBarsTemplateImpl(detailsConfig);
		},

		_subAvailable: function(request) {

			this.idDetails = null;
		},

		_subItemSelected: function() {

			this._publish(this.details.getChannel("HIDE"));
		},

		_subListBtnEvent: function(evt) {

			if (evt.btnId === "details") {
				if (this.idDetails) {
					this._publish(this.details.getChannel("HIDE"));

					if (this.idDetails === evt.id)
						this.idDetails = null;
					else {
						this.idDetails = null;
						this._subListBtnEvent(evt);
					}
				} else {
					this.rowNode = query("[data-redmic-id='" + evt.id + "']", this.listNode)[0].parentNode.parentNode.lastChild;
					this.idDetails = evt.id;

					this._once(this._buildChannel(this.storeChannel, this.actions.ITEM_AVAILABLE),
						lang.hitch(this, function(item) {
						this._publish(this.details.getChannel("SHOW"), {
							data: item.body.data,
							node: this.rowNode
						});
					}));

					this._publish(this._buildChannel(this.storeChannel, this.actions.GET), {
						id: evt.id,
						options: {},
						target: this.target,
						requesterId: this.getOwnChannel()
					});
				}
			}
		}
	});
});
+0 −76
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Selection"
	, "redmic/modules/base/_Show"
	, "./_DetailsItfc"
], function(
	declare
	, lang
	, _Module
	, _Selection
	, _Show
	, _DetailsItfc
){
	return declare([_Module, _DetailsItfc, _Selection, _Show], {
		//	summary:
		//		Muestra detalles de un item
		//	description:
		//		Proporciona métodos para mostrar los detalles de un item

		//	config: Object
		//		Opciones por defecto.

		constructor: function(args) {

			this.config = {
				template: null,
				showBtn: {},
				selection: {},
				idProperty: "id",
				// own events
				events: {
					NEXT: "next",
					BACK: "back",
					SELECTION: "selection",
					SET_CHECK_VALUE: "setCheckValue"
				},
				// own actions
				actions: {
					UPDATE_TEMPLATE: "updateTemplate"
				},
				// mediator params
				ownChannel: "details"
			};

			lang.mixin(this, this.config, args);

			this.title = this.i18n.details;
		},

		_defineSubscriptions: function () {

			this.subscriptionsConfig.push({
				channel : this.getChannel("UPDATE_TEMPLATE"),
				callback: "_subUpdateTemplate"
			});
		},

		_subUpdateTemplate: function(templateData) {

			this._updateTemplate(templateData);
		},

		_getItemToSelect: function(itemId) {

			return itemId;
		},

		_getItemToDeselect: function(itemId) {

			return itemId;
		}

	});
});
+0 −121
Original line number Diff line number Diff line
define([
	"dijit/_TemplatedMixin"
	, "dijit/_WidgetsInTemplateMixin"
	, "dijit/layout/ContentPane"
	, "dojo/_base/lang"
	, "dojo/_base/declare"
	, "./Details"
], function(
	_TemplatedMixin
	, _WidgetsInTemplateMixin
	, ContentPane
	, lang
	, declare
	, Details
){
	return declare(Details, {
		//	summary:
		//		Se definen los métodos necesarios para usar un Details module
		//	description:
		//		Proporciona la interfaz de los métodos usados en Details.js.

		//	config: Object
		//		Opciones por defecto.

		_setImplementationCallbacksForEvents: function() {

			this._onEvt('NEXT', lang.hitch(this, this._next));
			this._onEvt('BACK', lang.hitch(this, this._back));
			this._onEvt('SELECTION', lang.hitch(this, this._selection));
		},

		_showDetails: function(/*Object*/ request) {

			if(!request.body || !request.body.data)
				return;

			this.currentItem = request.body.data;

			var content = {
				bottomContent: this._getBottomContent && this._getBottomContent(),
				centerContent: this._render(request.body)
			};

			this._showContent(content, this.events.SHOW);

			this._setCheckedSelect();
		},

		_render: function(/*Object*/ item) {

			item.i18n = this.i18n;
			return new declare([ContentPane, _TemplatedMixin, _WidgetsInTemplateMixin])({
				region: "center",
				templateString: lang.replace(this.template, item)
			});
		},

		_showContent: function(/*Object*/ content, /*String*/ evt) {

			// No funciona (solo para el caso de que no esté en un dialog) Se le debe pasar un nodo y hacer un put.
			//TODO: meter this.bottomContent + el resultado del _render en un contenerdor y hacer el put de eso;
			console.warn("Warn: Método no implementado para cuando no está contenido en un dialog");
		},

		_setCheckedSelect: function() {

			this._emitEvt('SET_CHECK_VALUE', this._isSelected());
		},

		_hideContent: function(evt) {

			// No funciona (solo para el caso de que no esté en un dialog) Se le debe eliminar el nodo y emitir el evento pasado
			console.warn("Warn: Método no implementado para cuando no está contenido en un dialog");
		},

		_isSelected: function() {

			return this.currentItem && this.currentItem[this.idProperty] in this.selection;
		},

		_selection: function(state) {

			var eventToEmit = state ? 'SELECT' : 'DESELECT',
				ids = this.currentItem[this.idProperty];
			state ? this._select(ids) : this._deselect(ids);
			this._emitEvt(eventToEmit, {target: this.target, ids: ids});
		},

		_deselect: function(idProperty) {

			delete this.selection[idProperty];
		},

		_select: function(idProperty) {

			this.selection[idProperty] = true;
		},

		_clearSelection: function() {

			this.selection = {};
		},

		_getSelection: function() {

			return this.selection;
		},

		_back: function(/*Object*/ evt) {

			console.debug("dentro de back");
			this._setCheckedSelect();
		},

		_next: function(/*Object*/ evt) {

			console.debug("dentro de next");
			this._setCheckedSelect();
		}
	});
});
 No newline at end of file
+0 −139
Original line number Diff line number Diff line
define([
	"dojo/_base/lang"
	, "dojo/_base/declare"
	, "dojo/query"
	, "put-selector/put"
	, "RWidgets/TemplateWidget"
	, "templates/LoadingEmpty"
	, "./Details"
], function(
	lang
	, declare
	, query
	, put
	, TemplateWidget
	, LoadingEmpty
	, Details
){
	return declare(Details, {
		//	summary:
		//		Se definen los métodos necesarios para usar un Details module
		//	description:
		//		Proporciona la interfaz de los métodos usados en Details.js.

		//	config: Object
		//		Opciones por defecto.

		_initialize: function() {

			this._createInstance();
		},

		_createInstance: function() {

			this.templateWidget = new TemplateWidget({
				template: this.template,
				postTemplate: this.postTemplate,
				parentChannel: this.getChannel(),
				noDataMessage: LoadingEmpty()
			});

			this._listenEvents();
		},

		_listenEvents: function() {

			this.templateWidget.on(this.templateWidget.events.SHOWN, lang.hitch(this, this._emitTemplateShown));
			this.templateWidget.on(this.templateWidget.events.ERROR, lang.hitch(this, this._emitError));
			this.templateWidget.on(this.templateWidget.events.HIDE, lang.hitch(this, this._hide));
		},

		_setOwnCallbacksForEvents: function() {

			this._onEvt('NEXT', lang.hitch(this, this._next));
			this._onEvt('BACK', lang.hitch(this, this._back));
			this._onEvt('SELECTION', lang.hitch(this, this._selection));
		},

		_getNodeToShow: function() {

			this._render(this.currentData);
			this._setCheckedSelect();
			return this.templateWidget.domNode;
		},

		_render: function(item) {

			this.templateWidget.emit(this.templateWidget.events.RENDER, this.i18n, item);
		},

		_setCheckedSelect: function() {

			this._emitEvt('SET_CHECK_VALUE', this._isSelected());
		},

		_emitTemplateShown: function() {

			this._emitEvt('SHOW');
		},

		_emitError: function(/*Object*/ evt) {

			this._emitEvt('ERROR', evt);
		},

		_updateTemplate: function(templateData) {

			if(!templateData || !templateData.templateWidget || !templateData.i18n)
				return;

			this.template = templateData.templateWidget;
			this.i18n = templateData.i18n;
		},

		_isSelected: function() {

			return this.currentData && this.currentData[this.idProperty] in this.selection;
		},

		_selection: function(state) {

			var eventToEmit = state ? 'SELECT' : 'DESELECT',
				ids = this.currentData[this.idProperty];
			state ? this._select(ids) : this._deselect(ids);
			this._emitEvt(eventToEmit, {target: this.target, ids: ids});
		},

		_deselect: function(idProperty) {

			delete this.selection[idProperty];
		},

		_select: function(idProperty) {

			this.selection[idProperty] = true;
		},

		_clearSelection: function() {

			this.selection = {};
		},

		_getSelection: function() {

			return this.selection;
		},

		_back: function(/*Object*/ evt) {

			console.debug("dentro de back");
			this._setCheckedSelect();
		},

		_next: function(/*Object*/ evt) {

			console.debug("dentro de next");
			this._setCheckedSelect();
		}
	});
});
 No newline at end of file
+0 −29
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Itfc"
], function(
	declare
	, lang
	, _Itfc
){
	return declare(_Itfc, {
		//	summary:
		//		Interfaz de Details.
		//	description:
		//		Define los métodos que debe poseer la implementación.


		_getMethodsToImplement: function() {

			return lang.mixin(this.inherited(arguments), {
				"_setImplementationCallbacksForEvents": {},
				"_showDetails": {},
				"_hideContent": {},
				"_select": {},
				"_deselect": {},
				"_updateTemplate": {}
			});
		}
	});
});