Files
wekan/client/components/settings/sharedLabelsSettings.js
T
Lauri Ojansivu 6a7af5391a Accessibility: every Admin Panel pane and the most used popups pass the WCAG 2.2 AA rules, at 320 px and with reduced motion.
tests/playwright/specs/47-accessibility-everywhere.e2e.js scans every Admin
Panel pane and the member, list, swimlane and card details menus with axe,
checks 320 px reflow and that nothing animates when reduced motion is asked
for. What it found is fixed:

- names: every unnamed input and select of the Admin Panel is named by the
  label shown beside it; table page filters lost their label in
  models/lib/tablePage.js; people rows and avatar links name the person, and
  a person link's name starts with its visible initials (2.5.3);
- contrast: the feature descriptions, source badges, instrumentation headings
  and the default theme's menu hover pass 4.5:1;
- target size: checkbox rows, notification options and the Select all links
  are at least 24 x 24 px;
- the member menu's dependency toggles are checkboxes in a well-formed list;
- reduced motion: one rule in its own CSS layer makes every animation and
  transition instant, even those header.css marks !important.

Spec 47 passes in Chromium, and specs 45 and 46 still pass (39).
tests/accessibilitySpec47Fixes.test.cjs pins the fixes, and fails when a
settings select has no name.

Thanks to xet7 !
2026-11-24 19:14:11 +02:00

95 lines
4.0 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import SharedLabels from '/models/sharedLabels';
import Org from '/models/org';
import Team from '/models/team';
import { LABEL_COLORS } from '/models/metadata/colors';
// Admin Panel / Settings / Labels (#2761, #4698): each row is one shared
// label and saves on its own; the last row adds one. Saving goes through the
// site-admin method, which also renames and recolours every board's copy.
const SCOPE_LABELS = {
instance: 'shared-label-scope-instance',
org: 'shared-label-scope-org',
team: 'shared-label-scope-team',
};
Template.sharedLabelsSettings.onCreated(function () {
this.edits = new ReactiveVar({});
this.subscribe('sharedLabels');
// The organizations and teams a label can belong to (admin-only publications).
this.subscribe('org', {}, 1000);
this.subscribe('team', {}, 1000);
});
function current(tpl, id) {
const edit = tpl.edits.get()[id];
if (edit) return edit;
const saved = id === 'new' ? null : SharedLabels.findOne(id);
return saved
? { name: saved.name || '', color: saved.color, scope: saved.scope, scopeId: saved.scopeId || '' }
: { name: '', color: LABEL_COLORS[0], scope: 'instance', scopeId: '' };
}
function change(tpl, id, key, value) {
tpl.edits.set({ ...tpl.edits.get(), [id]: { ...current(tpl, id), [key]: value } });
}
Template.sharedLabelsSettings.helpers({
rows() {
const tpl = Template.instance();
const ids = SharedLabels.find({}, { sort: { sort: 1, name: 1 } }).map(l => l._id).concat(['new']);
return ids.map(id => {
const row = current(tpl, id);
const scopeIds = row.scope === 'org'
? Org.find({}, { sort: { orgDisplayName: 1 } }).map(o => ({ value: o._id, label: o.orgDisplayName }))
: Team.find({}, { sort: { teamDisplayName: 1 } }).map(t => ({ value: t._id, label: t.teamDisplayName }));
return {
id,
isNew: id === 'new',
name: row.name,
color: row.color,
// The picker hears a pick through set(); an object, not a function,
// because Spacebars would call a function argument instead of passing it.
colorSink: { set: color => change(tpl, id, 'color', color) },
scopeOptions: Object.keys(SCOPE_LABELS).map(value => ({ value, labelKey: SCOPE_LABELS[value], selected: value === row.scope })),
needsScopeId: row.scope !== 'instance',
// The organization or team picker is named after the scope it picks for.
scopeLabelKey: SCOPE_LABELS[row.scope],
scopeIdOptions: scopeIds.map(o => ({ ...o, selected: o.value === row.scopeId })),
};
});
},
});
const rowId = event => String($(event.currentTarget).closest('.shared-label-row').data('id'));
Template.sharedLabelsSettings.events({
'input .js-shared-label-name'(event, tpl) { change(tpl, rowId(event), 'name', event.currentTarget.value); },
'change .js-shared-label-scope'(event, tpl) {
change(tpl, rowId(event), 'scope', event.currentTarget.value);
change(tpl, rowId(event), 'scopeId', '');
},
'change .js-shared-label-scope-id'(event, tpl) { change(tpl, rowId(event), 'scopeId', event.currentTarget.value); },
'click .js-shared-label-save'(event, tpl) {
event.preventDefault();
const id = rowId(event);
const row = current(tpl, id);
// A first organization or team is the one the select shows when untouched.
if (row.scope !== 'instance' && !row.scopeId) {
row.scopeId = String(tpl.$(event.currentTarget).closest('.shared-label-row').find('.js-shared-label-scope-id').val() || '');
}
Meteor.call('sharedLabels.save', id === 'new' ? null : id, row, err => {
if (err) { console.error('sharedLabels.save', err); return; }
const edits = { ...tpl.edits.get() };
delete edits[id];
tpl.edits.set(edits);
});
},
'click .js-shared-label-delete'(event) {
event.preventDefault();
Meteor.call('sharedLabels.remove', rowId(event), err => { if (err) console.error('sharedLabels.remove', err); });
},
});