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

Implementa edición de los nuevos servicios OGC

Adapta el proceso de edición a la nueva estructura y formato definida
por la unidad funcional de atlas.
parent dfaaa81b
Loading
Loading
Loading
Loading
+105 −0
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, "redmic/modules/base/_Persistence"
	, 'redmic/modules/form/FormContainerImpl'
	, "redmic/modules/form/_ListenModelHasChanged"
	, 'redmic/modules/form/_PublicateChanges'
	, "redmic/modules/form/_ShowInDialog"
], function(
	declare
	, lang
	, aspect
	, _Persistence
	, FormContainerImpl
	, _ListenModelHasChanged
	, _PublicateChanges
	, _ShowInDialog
) {

	return declare(_Persistence, {
		//	summary:
		//		Extensión que añade input de texto y botón, para buscar contenido

		constructor: function(args) {

			this.config = {};

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

			aspect.before(this, '_afterSetConfigurations', lang.hitch(this, this._setAddAtlasCategoryConfigurations));
			aspect.after(this, '_beforeInitialize', lang.hitch(this, this._initializeAddAtlasCategory));
			aspect.after(this, '_defineSubscriptions', lang.hitch(this, this._defineAddAtlasCategorySubscriptions));
		},

		_setAddAtlasCategoryConfigurations: function() {

			this.formConfig = this._merge([{
				formContainerConfig: {
					onAddCategory: lang.hitch(this, this._onAddCategory)
				}
			}, this.formConfig || {}]);

			this.categoryFormConfig = this._merge([{
				parentChannel: this.getChannel(),
				template: 'maintenance/views/templates/forms/CategoryLayer',
				modelTarget: this.editionTarget
			}, this.categoryFormConfig || {}]);
		},

		_initializeAddAtlasCategory: function() {

			var formDefinition = declare([
				FormContainerImpl,
				_ListenModelHasChanged,
				_ShowInDialog
			]);

			this._categoryForm = new formDefinition(this.categoryFormConfig);
		},

		_defineAddAtlasCategorySubscriptions: function () {

			this.subscriptionsConfig.push({
				channel: this._categoryForm.getChannel("SUBMITTED"),
				callback: "_subCategoryFormSubmitted"
			});
		},

		_onAddCategory: function() {

			this._editCategory();
		},

		_editCategory: function(category) {

			this._publish(this._categoryForm.getChannel('SHOW'), {
				data: category,
				node: this.domNode
			});
		},

		_subCategoryFormSubmitted: function(res) {

			if (res.error) {
				return;
			}

			this._emitEvt('LOADING', {
				global: true
			});

			this._emitEvt('SAVE', {
				target: this.editionTarget,
				data: res.data
			});
		},

		_afterSaved: function(res) {

			this._publish(this._categoryForm.getChannel('HIDE'));
			this._emitEvt('LOADED');
		}
	});
});
+101 −0
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'redmic/modules/form/FormContainerImpl'
	, 'redmic/modules/form/_PublicateChanges'
	, './_AddTextSearchInputItfc'
], function(
	declare
	, lang
	, aspect
	, FormContainerImpl
	, _PublicateChanges
	, _AddTextSearchInputItfc
) {

	return declare(_AddTextSearchInputItfc, {
		//	summary:
		//		Extensión que añade input de texto y botón, para buscar contenido

		constructor: function(args) {

			this.config = {};

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

			aspect.before(this, '_afterSetConfigurations', lang.hitch(this, this._setAddTextSearchInputConfigurations));
			aspect.after(this, '_beforeInitialize', lang.hitch(this, this._initializeAddTextSearchInput));

			if (this._clearStep) {
				aspect.after(this, '_clearStep', lang.hitch(this, this._addTextSearchInputClearStep));
			}
		},

		_setAddTextSearchInputConfigurations: function() {

			this.formConfig = this._merge([{
				parentChannel: this.getChannel(),
				template: 'maintenance/views/templates/forms/ServiceOGCLayerSearch',
				modelChannel: this.modelChannel,
				formContainerConfig: {
					onNewSearch: lang.hitch(this, this._onNewSearch)
				}
			}, this.formConfig || {}]);
		},

		_initializeAddTextSearchInput: function() {

			var formDefinition = declare(FormContainerImpl).extend(_PublicateChanges);

			this._form = new formDefinition(this.formConfig);
		},

		_showTextSearch: function(parentNode) {

			this._publish(this._form.getChannel('SHOW'), {
				node: parentNode
			});
		},

		_onNewSearch: function() {

			this._once(this._form.getChannel('GOT_PROPERTY_VALUE'), lang.hitch(this, function(res) {

				var url = res.value;

				this._emitEvt('REQUEST', {
					target: this.target,
					action: 'wms',
					method: 'POST',
					query: {
						url: url
					}
				});
			}));

			this._publish(this._form.getChannel('GET_PROPERTY_VALUE'), {
				propertyName: 'urlSource'
			});
		},

		_dataAvailable: function(res) {

			this._onNewSearchResults(res.data);
		},

		_errorAvailable: function(error, status) {

			this._emitEvt('COMMUNICATION', {
				type: 'alert',
				level: 'error',
				description: error
			});
		},

		_addTextSearchInputClearStep: function() {

			this._publish(this._form.getChannel('CLEAR'));
		}
	});
});
+23 −0
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 _AddTextSearchInput.
		//	description:
		//		Define los métodos que debe poseer la implementación.

		_getMethodsToImplement: function() {

			return lang.mixin(this.inherited(arguments), {
				"_onNewSearchResults": {}
			});
		}
	});
});
 No newline at end of file
+21 −11
Original line number Diff line number Diff line
@@ -184,9 +184,17 @@ define([

		_pubRemove: function(channel, idProperty) {

			var id = idProperty,
				target = this._getTarget();

			if (idProperty && typeof idProperty === 'object') {
				target = idProperty.target || this._getTarget();
				id = idProperty[this.idProperty];
			}

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

@@ -204,13 +212,15 @@ define([

			alertify.confirm(this.i18n.deleteConfirmationTitle, this.i18n.deleteConfirmationMessage,
				lang.hitch(this, function(idProperty) {

				this._emitEvt('REMOVE_ITEM', idProperty);
			}, idProperty),
				lang.hitch(this, function(idProperty) {
			lang.hitch(this, function() {

				this._emitEvt('COMMUNICATION', {
					description: this.i18n.cancelledAlert
				});
				}, idProperty)).set("labels", {
			})).set("labels", {
				ok: this.i18n.ok,
				cancel: this.i18n.cancel
			});
+0 −63
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dojo/_base/lang"
	, "RWidgets/Button"
], function(
	declare
	, lang
	, Button
){
	return declare(null, {
		//	summary:
		//		Extensión para las vistas de edición de datos relativos a capas.
		//	description:
		//		Añade funcionalidades de edición a la vista.
		//		Ha de declararse junto con una extensión que aporte los métodos
		//		en los que se apoya.


		constructor: function(args) {

			this.config = {
				listButtonsEdition: [{
					groupId: "edition",
					icons:[{
						icon: "fa-edit",
						btnId: "categoryEdit",
						title: "edit",
						returnItem: true,
						option: "default",
						condition: this._checkItemIsCategory
					},{
						icon: "fa-trash-o",
						btnId: "remove",
						title: "remove",
						condition: this._checkItemIsCategory
					}]
				}]
			};

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

		_addEditionButtons: function() {

			if (this.buttonsNode) {
				this.addNewButton = new Button({
					iconClass: "fa fa-plus",
					'class': "success",
					title: this.i18n.addLayersCategory,
					onClick: lang.hitch(this, this._addNewLayersCategoryCallback)
				}).placeAt(this.buttonsNode);
			}
		},

		_addNewLayersCategoryCallback: function(evt) {

			this._emitEvt('SHOW_FORM', {
				//data: null,
				node: this._getNodeForForm()
			});
		}
	});
});
Loading