mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
A design that describes what WeKan already DOES belongs with the feature it describes, not in the folder for things being proposed. Fifteen docs move: Design/Accessibility.md -> Features/Accessibility/Accessibility-Improvements.md Design/Original-Positions.md -> Features/Board/Original-Positions.md Design/Page/* -> Features/Page/* (thirteen pages that exist) Design/AdminPanelProblems.md -> Features/Admin-Panel/Problems/Design.md What stays in docs/Design is what the folder is for: the principles (Design-Principles, Monkey-Proof-Software), the comparisons, the roadmap (Multiverse), and the proposals not yet built (Multitenancy, Autoupdate). The Admin Panel Problems design is new and covers six changes - summaries, the per-actor tally, IPv4/IPv6 columns, an API report, a per-address login tally, and blocking with increasing delays. Three are shipped and three are planned; it is filed under the feature because the pane exists, with each planned item marked so it can become plain description as it lands. Every reference in the repository is rewritten - 152 files, including the CSS comments that point at the table-page design, which a first pass over .md and .js alone missed. Two suites asserted the old paths and now assert the new ones. A moved doc whose links nobody fixed is worse than one nobody moved. 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/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(safeSelector(query || {}, 'getTranslationsCollectionCount'), {}, true);
|
|
return typeof cursor.countAsync === 'function' ? await cursor.countAsync() : cursor.count();
|
|
},
|
|
});
|
|
|
|
Meteor.startup(async () => {
|
|
await ensureIndex(Translation, { modifiedAt: -1 });
|
|
});
|