mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
A feature's guide now sits under the menu it is used from, read from the templates rather than from where somebody once put it: Header-Bar, All-Boards, Pages, Board-Header (search and every Board View), Board-Sidebar (Board Settings, Filter, Members, Labels, Archive), Rules, Swimlanes, Lists, Cards, Member-Settings, Admin-Panel and Login-Page. Topics used from several menus (editor, history, theme, translations, email, troubleshooting) are in General. - Each area has a README mapping its menu entries to their guides and to the template or server module that implements them. Board-Header/README.md lists all 40 Board View entries with the template boardBody.jade renders; five views (Table, Calendar Mode, Time, Timeline, Map) have no guide of their own yet and say so. - Board-View.md listed 25 views while BOARD_VIEWS has 40; it now lists all of them with their English labels. - Pages keep their file names. Where a released changelog links an old path, a "# Moved" page stays there and points to the new one; test-menu.sh skips folders holding only those. - Undo was filed under Login; it is General/Undo now. - Every link in docs, code comments, scripts and tests follows the move; docsLinksResolve checks them all. Tests that read a doc follow it to its new place. boardViewSettings now fails when Board-View.md or Board-Header/README.md differs from BOARD_VIEWS, or names a template boardBody.jade does not render. Thanks to xet7 !
70 lines
2.3 KiB
JavaScript
70 lines
2.3 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import Translation from '/models/translation';
|
|
import { safeSelector } from '/server/lib/selectorGuard';
|
|
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/Features/General/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(safeSelector(query || {}, 'getTranslationsCollectionCount'), {}, true);
|
|
return typeof cursor.countAsync === 'function' ? await cursor.countAsync() : cursor.count();
|
|
},
|
|
});
|
|
|
|
Meteor.startup(async () => {
|
|
await ensureIndex(Translation, { modifiedAt: -1 });
|
|
});
|