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

Recupera edición de user y gestión de selección

parent 6893bcdc
Loading
Loading
Loading
Loading
+13 −41
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ define([
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Store"
	, "redmic/modules/store/Persistence"
	, "redmic/modules/base/_Persistence"
	, "templates/SelectionList"
], function(
	alertify
@@ -18,10 +18,11 @@ define([
	, declare
	, lang
	, _Store
	, Persistence
	, _Persistence
	, TemplateList
) {
	return declare([Layout, Controller, _Main, _Store, _OnShownAndRefresh], {

	return declare([Layout, Controller, _Main, _Store, _Persistence, _OnShownAndRefresh], {
		//	summary:
		//		Extensión para establecer la vista de selección para cargar selecciones guardadas
		//
@@ -34,7 +35,6 @@ define([
					UPDATE_DATA: "updateData"
				},
				mainEvents: {
					REMOVE_ITEM: "removeItem",
					UPDATE_DATA: "updateData"
				},

@@ -69,9 +69,6 @@ define([
		_defineMainSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel: this.persistence.getChannel("REMOVED"),
				callback: "_subRemoved"
			},{
				channel: this.getChannel("UPDATE_TARGET"),
				callback: "_subUpdateTarget"
			});
@@ -82,17 +79,6 @@ define([
			this.publicationsConfig.push({
				event: 'UPDATE_DATA',
				channel: this.getChannel("UPDATE_DATA")
			},{
				event: 'REMOVE_ITEM',
				channel: this.persistence.getChannel("REMOVE"),
				callback: "_pubRemove"
			});
		},

		_initializeMain: function() {

			this.persistence = new Persistence({
				parentChannel: this.getChannel()
			});
		},

@@ -123,11 +109,17 @@ define([
				return;
			}

			alertify.confirm(this.i18n.deleteConfirmationTitle, this.i18n.deleteConfirmationMessage,
			alertify.confirm(this.i18n.deleteConfirmationTitle,
				this.i18n.deleteConfirmationMessage,
				lang.hitch(this, function(id) {
					this._emitEvt('REMOVE_ITEM', id);

					this._emitEvt('REMOVE', {
						target: this.target,
						id: id
					});
				}, data.id),
				lang.hitch(this, function(id) {

					this._emitEvt('COMMUNICATION', {
						description: this.i18n.cancelledAlert
					});
@@ -142,26 +134,6 @@ define([
			this._emitEvt('UPDATE_DATA', response);
		},

		_pubRemove: function(channel, id) {

			this._publish(channel, {
				target: this.target,
				id: id
			});
		},

		_subRemoved: function(result) {

			if (result.success) {
				this._refresh();
			}
		},

		_refresh: function() {

			this._emitEvt('REFRESH');
		},

		postCreate: function() {

			this.inherited(arguments);
+18 −46
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ define([
	, "dojo/_base/lang"
	, "redmic/base/Credentials"
	, "redmic/modules/base/_Window"
	, "redmic/modules/base/_Persistence"
	, "redmic/modules/browser/_ButtonsInRow"
	, "redmic/modules/browser/_MultiTemplate"
	, "redmic/modules/browser/ListImpl"
@@ -18,7 +19,6 @@ define([
	, "redmic/modules/form/_CreateKeypad"
	, "redmic/modules/form/FormContainerImpl"
	, "redmic/modules/form/_ListenModelHasChanged"
	, "redmic/modules/store/Persistence"
	, "templates/UserImage"
	, "templates/UserTitle"
	, "templates/UserEmail"
@@ -39,6 +39,7 @@ define([
	, lang
	, Credentials
	, _Window
	, _Persistence
	, _ButtonsInRow
	, _MultiTemplate
	, ListImpl
@@ -46,7 +47,6 @@ define([
	, _CreateKeypad
	, FormContainerImpl
	, _ListenModelHasChanged
	, Persistence
	, TemplateImage
	, TemplateTitle
	, TemplateEmail
@@ -56,7 +56,7 @@ define([
	, TaskNotification
) {

	return declare([Layout, Controller], {
	return declare([Layout, Controller, _Persistence], {
		//	summary:
		//		Vista detalle de user.

@@ -75,7 +75,6 @@ define([
					omitTitleCloseButton: true
				},
				events: {
					SAVED_FORM: "savedForm",
					ALL_TASK_SOCKET: "allTaskSocket"
				},
				actions: {
@@ -155,27 +154,9 @@ define([
			}, this.formBaseConfig || {}]);
		},

		_initialize: function() {

			this.persistence = new Persistence({
				parentChannel: this.getChannel()
			});
		},

		_defineSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel: this.persistence.getChannel("SAVED"),
				callback: "_subSaved"
			});
		},

		_definePublications: function() {

			this.publicationsConfig.push({
				event: 'SAVED_FORM',
				channel: this.persistence.getChannel("SAVE")
			},{
				event: 'ALL_TASK_SOCKET',
				channel: this._buildChannel(this.taskChannel, this.actions.ALL_TASK)
			});
@@ -186,13 +167,11 @@ define([
			this[response.item.callback]();
		},

		_subSaved: function(result) {
		_afterSaved: function(res) {

			this._emitEvt('LOADED');
			var result = res.data;

			if (!result.success) {
				return;
			}
			this._emitEvt('LOADED');

			result.hide = true;
			this._publish(this.formActive.getChannel("SAVED"), result);
@@ -200,11 +179,6 @@ define([
			this._showBoxUser(result.target);

			this._refreshModules();

			this._publish(this._buildChannel(this.storeChannel, this.actions.REQUEST), {
				target: redmicConfig.services.profile,
				type: this.type
			});
		},

		_nameEdit: function() {
@@ -280,16 +254,16 @@ define([

			if (!obj.noData) {
				this._once(this._buildChannel(this.storeChannel, this.actions.AVAILABLE),
					lang.hitch(this, function(item) {
						if (item && item.body && item.body.data) {
							this._showFormAndHideBoxUser(this.formActive, obj.labelNode, item.body.data);
					lang.hitch(this, function(resWrapper) {

					if (resWrapper && resWrapper.res && resWrapper.res.data) {
						this._showFormAndHideBoxUser(this.formActive, obj.labelNode, resWrapper.res.data);
					}
				}));

				this._publish(this._buildChannel(this.storeChannel, this.actions.REQUEST), {
				this._emitEvt('REQUEST', {
					target: obj.formConfig.target,
					requesterId: this.formActive.getOwnChannel(),
					type: this.type
					requesterId: this.formActive.getOwnChannel()
				});
			} else {
				this._showFormAndHideBoxUser(this.formActive, obj.labelNode);
@@ -317,6 +291,7 @@ define([
		_createSubscriptionsForm: function(instanceForm, obj) {

			this._subscribe(instanceForm.getChannel("CANCELLED"), lang.hitch(this, function(res) {

				this._showBoxUser(obj.formConfig.targetSave ? obj.formConfig.targetSave : obj.formConfig.target);
			}));

@@ -330,8 +305,8 @@ define([
					global: true
				});

				this._emitEvt('SAVED_FORM', {
					item: res.data,
				this._emitEvt('SAVE', {
					data: res.data,
					target: obj.formConfig.targetSave ? obj.formConfig.targetSave : obj.formConfig.target,
					idProperty: this.idProperty
				});
@@ -434,8 +409,6 @@ define([
				typeGroup: "password",
				template: TemplatePassword
			});

			this.startup();
		},

		_clearModules: function() {
@@ -454,10 +427,9 @@ define([

			this._emitEvt('ALL_TASK_SOCKET', {});

			this._publish(this._buildChannel(this.storeChannel, this.actions.REQUEST), {
			this._emitEvt('REQUEST', {
				target: this.target,
				requesterId: this.getOwnChannel(),
				type: this.type
				requesterId: this.getOwnChannel()
			});
		},

+20 −40
Original line number Diff line number Diff line
@@ -10,12 +10,12 @@ define([
	, "dojo/_base/lang"
	, "put-selector/put"
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Persistence"
	, "redmic/modules/base/_Selection"
	, "redmic/modules/base/_Show"
	, "redmic/modules/base/_ShowInTooltip"
	, "redmic/modules/base/_ShowOnEvt"
	, "redmic/modules/layout/listMenu/ListMenu"
	, "redmic/modules/store/Persistence"
	, "redmic/layout/DialogSimple"
	, "redmic/base/Credentials"
], function(
@@ -30,16 +30,16 @@ define([
	, lang
	, put
	, _Module
	, _Persistence
	, _Selection
	, _Show
	, _ShowInTooltip
	, _ShowOnEvt
	, ListMenu
	, Persistence
	, DialogSimple
	, Credentials
){
	return declare([_Module, _Show, _Selection], {
	return declare([_Module, _Show, _Selection, _Persistence], {
		//	summary:
		//		Indicador del número de seleccionados con botones asociados.
		//	description:
@@ -73,8 +73,7 @@ define([
				// mediator params
				ownChannel: "selectionBox",
				idProperty: "id",
				selectionToolsName: "selectionTools",
				selectionTargetSuffix: "/_selections"
				selectionTargetSuffix: "/_selections/"
			};

			lang.mixin(this, this.config, args);
@@ -128,12 +127,6 @@ define([
			this.subscriptionsConfig.push({
				channel : this.getChannel("REFRESH"),
				callback: "_subRefresh"
			},{
				channel: this.persistence.getChannel("SAVED"),
				callback: "_subSaved",
				options: {
					predicate: lang.hitch(this, this._chkSuccessful)
				}
			});

			if (this.menuInTooltip) {
@@ -150,10 +143,6 @@ define([
				event: 'REFRESH',
				channel: this.getChannel("REFRESHED"),
				callback: "_pubRefreshed"
			},{
				event: 'SAVE',
				channel: this.persistence.getChannel("SAVE"),
				callback: "_pubSave"
			},{
				event: 'TOTAL_SELECTED',
				channel: this.getChannel("TOTAL_SELECTED")
@@ -162,10 +151,6 @@ define([

		_initialize: function() {

			this.persistence = new Persistence({
				parentChannel: this.getChannel()
			});

			if (this.menuInTooltip) {
				this.loadSelectionListMenu = new declare([ListMenu, _ShowOnEvt])
					.extend(_ShowInTooltip)(this.listMenuSelectionConfig);
@@ -264,7 +249,7 @@ define([

		_exitsPermsCorrect: function(item) {

			return this.perms > 1 && this._isShowItem(item);
			return this.perms >= 1 && this._isShowItem(item);
		},

		_select: function(item, total) {
@@ -350,32 +335,32 @@ define([

			obj[this.idProperty] = this.idSelectionLoaded[this.idProperty];
			obj.name = this.idSelectionLoaded.name;
			this._emitEvt('SAVE', obj);
			this._emitEvt('SAVE', this._getDataToSave(obj));
		},

		_saveSelection: function(obj) {

			alertify.prompt(this.i18n.newNameMessage, "",
				lang.hitch(this, function(evt, value ) {
			alertify.prompt(this.i18n.newNameMessage, "", lang.hitch(this, function(evt, value ) {

				obj.name = value;
				delete this.idSelectionLoaded;
					this._emitEvt('SAVE', obj);
				this._emitEvt('SAVE', this._getDataToSave(obj));
			})).setHeader(this.i18n.saveSelection);
		},

		_pubSave: function(channel, item) {
		_getDataToSave: function(item) {

			this._publish(channel, {
			return {
				target: this.selectionTarget + this.selectionTargetSuffix,
				item: item,
				data: item,
				idProperty: this.idProperty
			});
			};
		},

		_subSaved: function(response) {
		_afterSaved: function(response) {

			if (response.success && response.body.id) {
				this.idSelectionLoaded = response.body;
			if (response.data && response.data.id) {
				this.idSelectionLoaded = response.data;
			}
		},

@@ -404,6 +389,7 @@ define([
				alertify.confirm(this.i18n.saveSelection,
					this.i18n.loseSelectionConfirmationMessage,
					lang.hitch(this, function() {

						delete this.idSelectionLoaded;
						this._showSelectionList();
					}),function(){})
@@ -461,12 +447,6 @@ define([
			};
		},

		_chkTargetAndRequester: function (response) {

			var result = this.inherited(arguments);
			return (result && response.body.requesterId) ? true : false;
		},

		_clearSelectionButtonCallback: function() {

			this._emitEvt('CLEAR_SELECTION');
+3 −3
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ define([
		_pubGroupSelected: function(channel) {

			this._publish(channel, {
				selectionTarget: this._getSelectionTarget()
				target: this._getSelectionTarget()
			});
		},

@@ -326,14 +326,14 @@ define([
		_pubGetTotal: function(channel) {

			this._publish(channel, {
				selectionTarget: this._getSelectionTarget(),
				target: this._getSelectionTarget(),
				requesterId: this.getOwnChannel()
			});
		},

		_subTotalAvailable: function(res) {

			res.success && this._totalAvailable(res.body);
			this._totalAvailable(res);
		},

		_chkSelectionTargetLoadingIsMine: function(res) {
+2 −2
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ define([

			var targetBase = this._getTargetBase(resWrapper.target);

			if (this.selections[targetBase] && response.data && response.data.ids) {
				this._selectedAll(response.data.ids, targetBase);
			if (this.selections[targetBase] && res.data && res.data.ids) {
				this._selectedAll(res.data.ids, targetBase);
			}
		},

Loading