Overview
Comment:Fix consistency and issues with multiples in input lists
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 48a25a7218385f737382a459d622bc75408e89ed
User & Date: bohwaz on 2020-10-01 11:12:34
Other Links: branch diff | manifest | tags
Context
2020-10-01
11:21
Display list of users linked to a transaction check-in: a0fe66f766 user: bohwaz tags: dev
11:12
Fix consistency and issues with multiples in input lists check-in: 48a25a7218 user: bohwaz tags: dev
2020-09-30
12:31
Fix focus after dialog close check-in: ddd5af655d user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Template.php from [36dcf1a90d] to [678031083a].

280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
		}
		elseif ($type == 'textarea') {
			$input = sprintf('<textarea %s>%s</textarea>', $attributes_string, $this->escape($current_value));
		}
		elseif ($type == 'list') {
			$multiple = !empty($attributes['multiple']);
			$values = '';
			$delete_btn = $this->widgetButton(['shape' => 'minus']);

			if (!is_array($current_value)) {
				$current_value = [];
			}

			foreach ($current_value as $v => $l) {
				$values .= sprintf('<span class="label"><input type="hidden" name="%s[%s]" value="%s" /> %3$s %s</span>', $this->escape($name), $this->escape($v), $this->escape($l), $multiple ? $delete_btn : '');







|







280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
		}
		elseif ($type == 'textarea') {
			$input = sprintf('<textarea %s>%s</textarea>', $attributes_string, $this->escape($current_value));
		}
		elseif ($type == 'list') {
			$multiple = !empty($attributes['multiple']);
			$values = '';
			$delete_btn = $this->widgetButton(['shape' => 'delete']);

			if (!is_array($current_value)) {
				$current_value = [];
			}

			foreach ($current_value as $v => $l) {
				$values .= sprintf('<span class="label"><input type="hidden" name="%s[%s]" value="%s" /> %3$s %s</span>', $this->escape($name), $this->escape($v), $this->escape($l), $multiple ? $delete_btn : '');

Modified src/templates/acc/accounts/selector.tpl from [bbba4e74fd] to [72132eb911].

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	return str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
}

var buttons = document.querySelectorAll('button');

buttons.forEach((e) => {
	e.onclick = () => {
		window.parent.inputListSelected(e.value, e.getAttribute('data-label'));
	};
});

buttons[0].focus();

var rows = document.querySelectorAll('table tr');








|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	return str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
}

var buttons = document.querySelectorAll('button');

buttons.forEach((e) => {
	e.onclick = () => {
		window.parent.g.inputListSelected(e.value, e.getAttribute('data-label'));
	};
});

buttons[0].focus();

var rows = document.querySelectorAll('table tr');

Modified src/templates/acc/transactions/new.tpl from [bd299f0d26] to [a2f0b252f3].

260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
			return false;
		};
		initLine(n);
		line.parentNode.appendChild(n);
	};
}

function inputListSelected(value, label) {
	var i = g.current_list_input;
	var multiple = i.firstChild.getAttribute('data-multiple');
	var name = i.firstChild.getAttribute('data-name');

	var span = document.createElement('span');
	span.className = 'label';
	span.innerHTML = '<input type="hidden" name="' + name + '[' + value + ']" value="' + label + '" />' + label;
	if (parseInt(multiple, 10) == 1) {
		var btn = document.createElement('button');
		btn.className = 'icn-btn';
		btn.type = 'button';
		btn.setAttribute('data-icon', '✘');
		btn.onclick = () => span.parentNode.removeChild(span);
		span.appendChild(btn);
	}
	i.appendChild(span);
	g.closeDialog();
	i.firstChild.focus();
}

initForm();
</script>
{/literal}

{include file="admin/_foot.tpl"}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





260
261
262
263
264
265
266





















267
268
269
270
271
			return false;
		};
		initLine(n);
		line.parentNode.appendChild(n);
	};
}






















initForm();
</script>
{/literal}

{include file="admin/_foot.tpl"}

Modified src/templates/admin/membres/selector.tpl from [fc909a80c9] to [908da99bf1].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

{literal}
<script type="text/javascript">
var buttons = document.querySelectorAll('button');

buttons.forEach((e) => {
	e.onclick = () => {
		window.parent.inputListSelected(e.value, e.getAttribute('data-label'));
	};
});

if (buttons.length) {
	buttons[0].focus();
}








|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

{literal}
<script type="text/javascript">
var buttons = document.querySelectorAll('button');

buttons.forEach((e) => {
	e.onclick = () => {
		window.parent.g.inputListSelected(e.value, e.getAttribute('data-label'));
	};
});

if (buttons.length) {
	buttons[0].focus();
}

Modified src/www/admin/static/scripts/global.js from [be3bfcf214] to [c2c45e5176].

214
215
216
217
218
219
220
























221
222
223
224
225
226
227
228
229
230
231






232
233
234
235
236
237
238
		};
		span.appendChild(btn);
		input.parentNode.insertBefore(span, input.nextSibling);
	};

	g.current_list_input = null;

























		// Sélecteurs de listes
	g.onload(() => {
		var inputs = $('form .input-list button');

		inputs.forEach((i) => {
			i.onclick = () => {
				g.current_list_input = i.parentNode;
				g.openFrameDialog(i.value);
				return false;
			};
		});






	});

	g.onload(() => {
		document.querySelectorAll('input[data-input="date"]').forEach((e) => {
			g.enhanceDateField(e);
		});
	});







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|








>
>
>
>
>
>







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
		};
		span.appendChild(btn);
		input.parentNode.insertBefore(span, input.nextSibling);
	};

	g.current_list_input = null;

	g.inputListSelected = function(value, label) {
		var i = g.current_list_input;
		var multiple = i.firstChild.getAttribute('data-multiple');
		var name = i.firstChild.getAttribute('data-name');

		var span = document.createElement('span');
		span.className = 'label';
		span.innerHTML = '<input type="hidden" name="' + name + '[' + value + ']" value="' + label + '" />' + label;

		// Add delete button
		if (parseInt(multiple, 10) == 1) {
			var btn = document.createElement('button');
			btn.className = 'icn-btn';
			btn.type = 'button';
			btn.setAttribute('data-icon', '✘');
			btn.onclick = () => span.parentNode.removeChild(span);
			span.appendChild(btn);
		}

		i.appendChild(span);
		g.closeDialog();
		i.firstChild.focus();
	};

	// Sélecteurs de listes
	g.onload(() => {
		var inputs = $('form .input-list > button');

		inputs.forEach((i) => {
			i.onclick = () => {
				g.current_list_input = i.parentNode;
				g.openFrameDialog(i.value);
				return false;
			};
		});

		var multiples = $('form .input-list span button');

		multiples.forEach((btn) => {
			btn.onclick = () => btn.parentNode.parentNode.removeChild(btn.parentNode);
		});
	});

	g.onload(() => {
		document.querySelectorAll('input[data-input="date"]').forEach((e) => {
			g.enhanceDateField(e);
		});
	});