mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Reported one after another, all in the Admin Panel, and they turned out to share
two causes: a stylesheet deciding a table's width from outside the design that
owns it, and a pane having to write for itself what every pane needs.
The tables
* Admin Panel / People / People rendered NOTHING - no table, no search box, no
pager. `buildFilters` and `buildActions` were used in peopleTablePageData but
never imported. That is not a build error: it is a ReferenceError thrown inside
a helper while rendering, which Blaze answers by rendering nothing at all.
Organizations, Teams and Domains use neither function, so they drew normally,
which is what made it look like a People-only problem.
* The right-hand side of a table was off screen - reported on Domains, and just
as true of Admin Panel / Version, where the value column was cut off at the
window edge. Two admin stylesheets forced `min-width: 1200px !important;
width: max-content !important` with nowrap cells on a bare `table` selector.
peopleBody.css had no page in the selector at all, so it reached every table in
WeKan, and `!important` beat the shared table page's own width:100% +
table-layout:fixed. The same rules also made a SHORT table shrink to its
content, which is why Domains sat at a third of the panel on a narrow window.
No admin table is forced wide any more: it fits its panel and its cells wrap,
and the phone-width exception that used to undo the floor is simply the rule at
every width. The shared table page's width and wrapping are `!important` now -
a guarantee a stylesheet in another folder can silently override is not a
guarantee.
* An empty table page rendered no table at all, and the "New" link of
Organizations, Teams, People and Translation is a column HEADER - so an empty
pane had no way to create the first row. The table always renders now; the
"no items" message moved below it.
* The controls row: every control shares one height and no margin. forms.css is
`button { display: block; margin-bottom: 14px }`, written for stacked form
buttons, so a button that kept that margin was centred higher than one that did
not - "Unlock all users" sat lower and shorter than "Teams" beside it, since it
also carried a 20px margin and a 28px height from the old hand-written header.
Action buttons are themed with the pager, in the one stylesheet that owns those
colours, every state spelled out, or a bare <button> falls through to the
forms.css fallback, which is literally black.
Admin Panel / Settings / Translation now renders through the shared table page
(docs/Design/Page/Table.md) instead of a hand-written table: four columns, an
interactive row, the "New" link as a column header. It pages ONE page of 25
server-side with limit/skip and a count method, where it used to grow a window by
infinite scroll; the publication publishes the field it is sorted by, so the
client's sort matches the server's page.
The pane title
Every Admin Panel pane opens with the same heading, and the heading is the ACTIVE
LEFT MENU ENTRY's own label - `paneTitle()` in models/lib/leftMenu.js, one class
`.admin-pane-title`, which the shared table page's own title carries too. Before
this only the paginated table pages had a title at all: Domains said "Domains"
while Login, Announcement, Accessibility, PWA and Version opened with no heading.
Deriving it from the menu is what keeps them identical - a pane cannot end up with
a title of a different size or none at all - and it is why a table page inside the
Admin Panel now passes no titleKey: the section already rendered the heading.
The menus
* Version is the FIRST pane of Admin Panel / Settings and the one that opens with
the page, so what an admin sees first is the version, database and system
information they usually came for. Its page, its one-entry menu and its tab are
gone - a page whose menu had a single entry was a page in name only - and
/information redirects to Settings, the same move Translation made.
* Admin Panel / People: Domains moves up beside E-mail, the settings it is about.
* Admin Panel / Attachments: Backup moves to the top.
Tests: tests/tablePage.test.cjs gains the Translation conversion, the empty-table
header, the one-height controls row, the themed actions and a guard that no admin
stylesheet may force a table's width; tests/leftMenu.test.cjs gains the pane title
(helper, template, every page renders it, one shared size) and Version as the
first Settings pane; tests/translationPane.test.cjs is rewritten for the pane that
is left once the shared design owns the table.
Thanks to xet7 !
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import Translation from '/models/translation';
|
|
import { ensureIndex } from '/server/lib/mongoStartup';
|
|
|
|
const getReactiveCache = () => require('/imports/reactiveCache').ReactiveCache;
|
|
|
|
Meteor.methods({
|
|
async setCreateTranslation(language, text, translationText) {
|
|
check(language, String);
|
|
check(text, String);
|
|
check(translationText, String);
|
|
|
|
if (!(await getReactiveCache().getCurrentUser())?.isAdmin) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
|
|
const nTexts = (await getReactiveCache().getTranslations({ language, text })).length;
|
|
if (nTexts > 0) {
|
|
throw new Meteor.Error('text-already-taken');
|
|
}
|
|
|
|
await Translation.insertAsync({
|
|
language,
|
|
text,
|
|
translationText,
|
|
});
|
|
},
|
|
|
|
async setTranslationText(translation, translationText) {
|
|
check(translation, Object);
|
|
check(translationText, String);
|
|
|
|
if (!(await getReactiveCache().getCurrentUser())?.isAdmin) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
|
|
await Translation.updateAsync(translation, {
|
|
$set: { translationText },
|
|
});
|
|
},
|
|
|
|
async deleteTranslation(translationId) {
|
|
check(translationId, String);
|
|
|
|
if (!(await getReactiveCache().getCurrentUser())?.isAdmin) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
|
|
await Translation.removeAsync(translationId);
|
|
},
|
|
|
|
// The total behind the "page X / N" counter of the Translation table page
|
|
// (docs/Design/Page/Table.md). It counts the whole result set - the page itself
|
|
// only ever holds 25 rows - so it is a separate call, made when the pane opens
|
|
// and when the search changes, never on a prev/next click.
|
|
async getTranslationsCollectionCount(query = {}) {
|
|
check(query, Match.OneOf(Object, null, undefined));
|
|
if (!(await getReactiveCache().getCurrentUser())?.isAdmin) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
const cursor = await getReactiveCache().getTranslations(query || {}, {}, true);
|
|
return typeof cursor.countAsync === 'function' ? await cursor.countAsync() : cursor.count();
|
|
},
|
|
});
|
|
|
|
Meteor.startup(async () => {
|
|
await ensureIndex(Translation, { modifiedAt: -1 });
|
|
});
|