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

Adapta edición de category y refresh de layer

parent eeb5827b
Loading
Loading
Loading
Loading
+0 −108
Original line number Diff line number Diff line
define([
	'alertify/alertify.min'
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "RWidgets/Button"
], function(
	alertify
	, 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-refresh",
						btnId: "update",
						title: "update",
						option: "default",
						condition: "urlSource"
					},{
						icon: "fa-edit",
						btnId: "edit",
						title: "edit",
						href: this.viewPaths.serviceOGCEdit,
						option: "default",
						condition: "urlSource"
					},{
						icon: "fa-edit",
						btnId: "categoryEdit",
						title: "edit",
						returnItem: true,
						option: "default",
						condition: this._checkItemIsCategory
					},{
						icon: "fa-trash-o",
						btnId: "remove",
						title: "remove"
					}]
				}]
			};

			lang.mixin(this, this.config);

		},

		_addEditionButtons: function() {

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

		_promptForUrl: function() {

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

					var regExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;

					var obj = {
						'url': value
					};

					if (regExp.test(value)) {
						this._emitEvt('SAVE', this._getObjToSave(obj));
					} else {
						this._urlInvalid(obj);
					}
				}))
				.setHeader(this.i18n.addLayers)
				.set("labels", {
					ok: this.i18n.add,
					cancel: this.i18n.cancel
				});
		},

		_getObjToSave: function(data) {

			return {
				target: this._getTarget(),
				item: data,
				idProperty: this.idProperty
			};
		},

		_urlInvalid: function(obj) {

			alertify.alert(this.i18n.invalidURL, this.i18n.invalidURLMessage + obj.url);
		}
	});
});
+56 −44
Original line number Diff line number Diff line
define([
	"app/base/views/extensions/_Edition"
	"app/base/views/extensions/_EditionWizardView"
	, "app/base/views/extensions/_FormInDialogView"
	, "app/maintenance/models/CategoryLayerModel"
	, "app/redmicConfig"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/aspect"
	, "redmic/modules/store/Persistence"
], function(
	_Edition
	_EditionWizardView
	, _FormInDialogView
	, CategoryLayerModel
	, redmicConfig
	, declare
	, lang
	, aspect
	, Persistence
){
	return declare([_Edition, _FormInDialogView], {
	return declare([_EditionWizardView, _FormInDialogView], {
		//	summary:
		//		Extensión para las vistas de edición de datos relativos a capas.
		//	description:
@@ -38,7 +36,6 @@ define([

			aspect.before(this, "_mixEventsAndActions", lang.hitch(this, this._mixEditionLayerEventsAndActions));
			aspect.before(this, "_afterSetConfigurations", lang.hitch(this, this._setEditionLayerConfigurations));
			aspect.after(this, "_beforeInitialize", lang.hitch(this, this._initializeEditionView));
		},

		_setEditionLayerConfigurations: function() {
@@ -47,6 +44,36 @@ define([
				template: "maintenance/views/templates/forms/CategoryLayer",
				modelSchema: CategoryLayerModel
			}, this.formConfig || {}]);

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

		_mixEditionLayerEventsAndActions: function() {
@@ -58,31 +85,10 @@ define([
			delete this.editionLayerActions;
		},

		_initializeEditionView: function() {

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

		_defineEditionSubscriptions: function () {

			this.inherited(arguments);

			this.subscriptionsConfig.push({
				channel: this.persistence.getChannel("REMOVED"),
				callback: "_subRemoved",
				options: {
					predicate: lang.hitch(this, this._chkSuccessful)
				}
			},{
				channel: this.persistence.getChannel("SAVED"),
				callback: "_subSaved",
				options: {
					predicate: lang.hitch(this, this._chkSuccessful)
				}
			});

			if (this.editor) {
				this.subscriptionsConfig.push({
					channel: this.editor.getChannel("SUBMITTED"),
@@ -95,11 +101,6 @@ define([

			this.inherited(arguments);

			this.publicationsConfig.push({
				event: 'SAVE',
				channel: this.persistence.getChannel("SAVE")
			});

			if (this.editor) {
				this.publicationsConfig.push({
					event: 'SAVED',
@@ -118,16 +119,21 @@ define([
			this._onEvt('UPDATE', lang.hitch(this, this._updateElement));
		},

		_updateElement: function(id) {
		_updateElement: function(layer) {

			var layerName = layer.name,
				layerSource = layer.urlSource,
				target = lang.replace(redmicConfig.services.atlasLayerRefresh, layer);

			var request = {
				'id': id
			var data = {
				urlSource: layerSource,
				name: layerName
			};

			this._emitEvt('SAVE', {
				target: redmicConfig.services.serviceOGCRefresh,
				item: request,
				idProperty: this.idProperty
				target: target,
				data: data,
				idInTarget: true
			});
		},

@@ -148,13 +154,16 @@ define([

		_updateCallback: function(evt) {

			this._emitEvt('UPDATE', evt.id);
			var layer = evt.item;
			this._emitEvt('UPDATE', layer);
		},

		_categoryEditCallback: function(res) {

			var category = res.item;

			this._emitEvt('SHOW_FORM', {
				data: res.item,
				data: category,
				node: this._getNodeForForm()
			});
		},
@@ -170,16 +179,19 @@ define([
				return;
			}

			var data = res.data;
			var data = res.data,
				target = lang.replace(redmicConfig.services.atlasCategoryEdition, data);

			delete data[this.idProperty];

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

			this._emitEvt('SAVE', {
				target: redmicConfig.services.serviceOGCCategory,
				item: data,
				idProperty: this.idProperty
				target: target,
				data: data,
				idInTarget: true
			});
		},

+4 −11
Original line number Diff line number Diff line
define([
	"app/redmicConfig"
], function (
	redmicConfig
){
define([], function() {

	return {
		"$schema": "http://json-schema.org/schema#",
		title: "CategoryLayer schema",
		type: "object",
		required: ["name", "atlas"],
		required: ["name"],
		properties: {
			id: {
				type: ["string", "null"]
			},
			name: {
				type: "string"
			},
			atlas: {
				'default': "false",
				type: "boolean"
			}
		}
	};
+3 −4
Original line number Diff line number Diff line
define([
	"app/designs/textSearchFacetsList/main/ServiceOGC"
	, "app/base/views/extensions/_EditionLayerElementView"
	, "app/base/views/extensions/_EditionLayerView"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
], function (
	ServiceOGCMain
	, _EditionLayerElementView
	, _EditionLayerView
	, declare
	, lang
){
	return declare([ServiceOGCMain, _EditionLayerView, _EditionLayerElementView], {
	return declare([ServiceOGCMain, _EditionLayerView], {
		//	summary:
		//		Vista de ServiceOGC.

@@ -21,7 +19,8 @@ define([
		constructor: function (args) {

			this.config = {
				ownChannel: "serviceOGC"
				ownChannel: "serviceOGC",
				addPath: this.viewPaths.serviceOGCAdd
			};

			lang.mixin(this, this.config, args);
+0 −2
Original line number Diff line number Diff line
<div>
	<form class="form-horizontal">
		<div data-redmic-type="text" data-redmic-model="name"></div>

		<div data-redmic-type="boolean" data-redmic-model="atlas"></div>
	</form>
</div>
 No newline at end of file
Loading