Commit b1c9483c authored by CarlosGC1989's avatar CarlosGC1989
Browse files

Refactoriza highlight de listado

parent df6c55e8
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ define([
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Show"
	, "redmic/modules/base/_Store"
	, "RWidgets/Utilities"
	, "put-selector/put"
	, "./_BrowserItfc"
	, "./_NoDataTemplate"
@@ -17,7 +16,6 @@ define([
	, _Module
	, _Show
	, _Store
	, Utilities
	, put
	, _BrowserItfc
	, _NoDataTemplate
@@ -85,8 +83,6 @@ define([
			aspect.after(this, "_removeItem", lang.hitch(this, this._emitEvt, 'DATA_REMOVED'));
			aspect.after(this, "_clearData", lang.hitch(this, this._emitEvt, 'CLEARED'));
			aspect.after(this, "_updateTemplate", lang.hitch(this, this._emitEvt, 'TEMPLATE_UPDATED'));

			aspect.before(this, "_addItem", lang.hitch(this, this._addReplaceHighlightInItem));
		},

		_defineSubscriptions: function () {
@@ -449,24 +445,6 @@ define([
			}

			return true;
		},

		_addReplaceHighlightInItem: function(item) {

			if (item && item._meta) {
				var highlight = item._meta.highlight;

				for (var content in highlight) {
					var value = '',
						attr = highlight[content];

					for (var i = 0; i < attr.length; i++) {
						value += attr[i];
					}

					Utilities.setDeepProp(item, content, value);
				}
			}
		}
	});
});
+30 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ define([
	, "dojo/_base/lang"
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Show"
	, "RWidgets/Utilities"
	, "put-selector/put"
	, "./_RowItfc"
], function(
@@ -10,6 +11,7 @@ define([
	, lang
	, _Module
	, _Show
	, Utilities
	, put
	, _RowItfc
){
@@ -91,6 +93,8 @@ define([

			put(this.templateNode, "[data-redmic-id=$]", this._getId(item));

			this._replaceHighlightInItem(item);

			this.templateNode.innerHTML = this._insertTemplate(item);
		},

@@ -143,6 +147,32 @@ define([
		_getNodeToShow: function() {

			return this.domNode;
		},

		_replaceHighlightInItem: function(item) {

			if (item && item._meta) {
				var highlight = item._meta.highlight;

				for (var content in highlight) {
					var value = Utilities.getDeepProp(item, content),
						attr = highlight[content];

					for (var i = 0; i < attr.length; i++) {
						var valueReplace = attr[i],
							cleanValueReplace = this._cleanValueHighlight(valueReplace);

						value = value.replace(cleanValueReplace, valueReplace);
					}

					Utilities.setDeepProp(item, content, value);
				}
			}
		},

		_cleanValueHighlight: function(value) {

			return value.replace(/<b>/g, '').replace(/<\/b>/g, '');
		}
	});
});
+4 −5
Original line number Diff line number Diff line
@@ -11,13 +11,12 @@ define([
) {

	new DataLoader({
		urlValue: '/data-loader/activity/522/area',
		wizardEditionUrlValue: '/data-loader/activity/1143/geo-data/edit/b7df3428-5d0c-4975-bce5-94a937381a87',
		wizardLoadUrlValue: '/data-loader/activity/1143/geo-data/add/new',
		textSearchValue: 'Mencáfete',
		urlValue: '/data-loader/activity/1152/area',
		wizardEditionUrlValue: '/data-loader/activity/1152/geo-data/edit/78883b11-e89d-44f9-aece-d86763882358',
		wizardLoadUrlValue: '/data-loader/activity/1152/geo-data/add/new',
		textSearchValue: 'Aguas interiores',
		namePrefix: 'Area data loader page',


		configSteps: [{
			type: 'form',
			required: true