123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920 |
- import { ReactiveCache } from '/imports/reactiveCache';
- import { TAPi18n } from '/imports/i18n';
- Sidebar = null;
- const defaultView = 'home';
- const MCB = '.materialCheckBox';
- const CKCLS = 'is-checked';
- const viewTitles = {
- filter: 'filter-cards',
- search: 'search-cards',
- multiselection: 'multi-selection',
- customFields: 'custom-fields',
- archives: 'archives',
- };
- BlazeComponent.extendComponent({
- mixins() {
- return [Mixins.InfiniteScrolling];
- },
- onCreated() {
- this._isOpen = new ReactiveVar(false);
- this._view = new ReactiveVar(defaultView);
- this._hideCardCounterList = new ReactiveVar(false);
- this._hideBoardMemberList = new ReactiveVar(false);
- Sidebar = this;
- },
- onDestroyed() {
- Sidebar = null;
- },
- isOpen() {
- return this._isOpen.get();
- },
- open() {
- if (!this._isOpen.get()) {
- this._isOpen.set(true);
- EscapeActions.executeUpTo('detailsPane');
- }
- },
- hide() {
- if (this._isOpen.get()) {
- this._isOpen.set(false);
- }
- },
- toggle() {
- this._isOpen.set(!this._isOpen.get());
- },
- calculateNextPeak() {
- const sidebarElement = this.find('.js-board-sidebar-content');
- if (sidebarElement) {
- const altitude = sidebarElement.scrollHeight;
- this.callFirstWith(this, 'setNextPeak', altitude);
- }
- },
- reachNextPeak() {
- const activitiesComponent = this.childComponents('activities')[0];
- activitiesComponent.loadNextPage();
- },
- isTongueHidden() {
- return this.isOpen() && this.getView() !== defaultView;
- },
- scrollTop() {
- this.$('.js-board-sidebar-content').scrollTop(0);
- },
- getView() {
- return this._view.get();
- },
- setView(view) {
- view = _.isString(view) ? view : defaultView;
- if (this._view.get() !== view) {
- this._view.set(view);
- this.scrollTop();
- EscapeActions.executeUpTo('detailsPane');
- }
- this.open();
- },
- isDefaultView() {
- return this.getView() === defaultView;
- },
- getViewTemplate() {
- return `${this.getView()}Sidebar`;
- },
- getViewTitle() {
- return TAPi18n.__(viewTitles[this.getView()]);
- },
- showTongueTitle() {
- if (this.isOpen()) return `${TAPi18n.__('sidebar-close')}`;
- else return `${TAPi18n.__('sidebar-open')}`;
- },
- events() {
- return [
- {
- 'click .js-hide-sidebar': this.hide,
- 'click .js-toggle-sidebar': this.toggle,
- 'click .js-back-home': this.setView,
- 'click .js-toggle-minicard-label-text'() {
- currentUser = Meteor.user();
- if (currentUser) {
- Meteor.call('toggleMinicardLabelText');
- } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
- window.localStorage.removeItem('hiddenMinicardLabelText');
- location.reload();
- } else {
- window.localStorage.setItem('hiddenMinicardLabelText', 'true');
- location.reload();
- }
- },
- 'click .js-shortcuts'() {
- FlowRouter.go('shortcuts');
- },
- 'click .js-close-sidebar'() {
- Sidebar.toggle()
- },
- },
- ];
- },
- }).register('sidebar');
- Blaze.registerHelper('Sidebar', () => Sidebar);
- Template.homeSidebar.helpers({
- hiddenMinicardLabelText() {
- currentUser = Meteor.user();
- if (currentUser) {
- return (currentUser.profile || {}).hiddenMinicardLabelText;
- } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
- return true;
- } else {
- return false;
- }
- },
- });
- Template.boardInfoOnMyBoardsPopup.helpers({
- hideCardCounterList() {
- return Utils.isMiniScreen() && Session.get('currentBoard');
- },
- hideBoardMemberList() {
- return Utils.isMiniScreen() && Session.get('currentBoard');
- },
- });
- EscapeActions.register(
- 'sidebarView',
- () => {
- Sidebar.setView(defaultView);
- },
- () => {
- return Sidebar && Sidebar.getView() !== defaultView;
- },
- );
- Template.memberPopup.helpers({
- user() {
- return Users.findOne(this.userId);
- },
- isBoardAdmin() {
- return Meteor.user().isBoardAdmin();
- },
- memberType() {
- const type = Users.findOne(this.userId).isBoardAdmin() ? 'admin' : 'normal';
- if (type === 'normal') {
- const currentBoard = Utils.getCurrentBoard();
- const commentOnly = currentBoard.hasCommentOnly(this.userId);
- const noComments = currentBoard.hasNoComments(this.userId);
- const worker = currentBoard.hasWorker(this.userId);
- if (commentOnly) {
- return TAPi18n.__('comment-only');
- } else if (noComments) {
- return TAPi18n.__('no-comments');
- } else if (worker) {
- return TAPi18n.__('worker');
- } else {
- return TAPi18n.__(type);
- }
- } else {
- return TAPi18n.__(type);
- }
- },
- isInvited() {
- return Users.findOne(this.userId).isInvitedTo(Session.get('currentBoard'));
- },
- });
- Template.boardMenuPopup.events({
- 'click .js-rename-board': Popup.open('boardChangeTitle'),
- 'click .js-open-rules-view'() {
- Modal.openWide('rulesMain');
- Popup.back();
- },
- 'click .js-custom-fields'() {
- Sidebar.setView('customFields');
- Popup.back();
- },
- 'click .js-open-archives'() {
- Sidebar.setView('archives');
- Popup.back();
- },
- 'click .js-change-board-color': Popup.open('boardChangeColor'),
- 'click .js-change-background-image': Popup.open('boardChangeBackgroundImage'),
- 'click .js-board-info-on-my-boards': Popup.open('boardInfoOnMyBoards'),
- 'click .js-change-language': Popup.open('changeLanguage'),
- 'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
- const currentBoard = Utils.getCurrentBoard();
- currentBoard.archive();
- // XXX We should have some kind of notification on top of the page to
- // confirm that the board was successfully archived.
- FlowRouter.go('home');
- }),
- 'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
- const currentBoard = Utils.getCurrentBoard();
- Popup.back();
- Boards.remove(currentBoard._id);
- FlowRouter.go('home');
- }),
- 'click .js-outgoing-webhooks': Popup.open('outgoingWebhooks'),
- 'click .js-import-board': Popup.open('chooseBoardSource'),
- 'click .js-subtask-settings': Popup.open('boardSubtaskSettings'),
- 'click .js-card-settings': Popup.open('boardCardSettings'),
- 'click .js-minicard-settings': Popup.open('boardMinicardSettings'),
- 'click .js-export-board': Popup.open('exportBoard'),
- });
- Template.boardMenuPopup.onCreated(function() {
- this.apiEnabled = new ReactiveVar(false);
- Meteor.call('_isApiEnabled', (e, result) => {
- this.apiEnabled.set(result);
- });
- });
- Template.boardMenuPopup.helpers({
- isBoardAdmin() {
- return Meteor.user().isBoardAdmin();
- },
- withApi() {
- return Template.instance().apiEnabled.get();
- },
- exportUrl() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- };
- return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
- },
- exportFilename() {
- const boardId = Session.get('currentBoard');
- return `export-board-${boardId}.json`;
- },
- });
- Template.memberPopup.events({
- 'click .js-filter-member'() {
- Filter.members.toggle(this.userId);
- Popup.back();
- },
- 'click .js-change-role': Popup.open('changePermissions'),
- 'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
- // This works from removing member from board, card members and assignees.
- const boardId = Session.get('currentBoard');
- const memberId = this.userId;
- Cards.find({ boardId, members: memberId }).forEach(card => {
- card.unassignMember(memberId);
- });
- Cards.find({ boardId, assignees: memberId }).forEach(card => {
- card.unassignAssignee(memberId);
- });
- ReactiveCache.getBoard(boardId).removeMember(memberId);
- Popup.back();
- }),
- 'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => {
- const boardId = Session.get('currentBoard');
- Meteor.call('quitBoard', boardId, () => {
- Popup.back();
- FlowRouter.go('home');
- });
- }),
- });
- Template.removeMemberPopup.helpers({
- user() {
- return Users.findOne(this.userId);
- },
- board() {
- return Utils.getCurrentBoard();
- },
- });
- Template.leaveBoardPopup.helpers({
- board() {
- return Utils.getCurrentBoard();
- },
- });
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- this.findOrgsOptions = new ReactiveVar({});
- this.findTeamsOptions = new ReactiveVar({});
- this.page = new ReactiveVar(1);
- this.teamPage = new ReactiveVar(1);
- this.autorun(() => {
- const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
- });
- this.autorun(() => {
- const limitTeams = this.teamPage.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('team', this.findTeamsOptions.get(), limitTeams, () => {});
- });
- },
- onRendered() {
- this.setLoading(false);
- Utils.setBackgroundImage();
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- tabs() {
- return [
- { name: TAPi18n.__('people'), slug: 'people' },
- { name: TAPi18n.__('organizations'), slug: 'organizations' },
- { name: TAPi18n.__('teams'), slug: 'teams' },
- ];
- },
- }).register('membersWidget');
- Template.membersWidget.helpers({
- isInvited() {
- const user = Meteor.user();
- return user && user.isInvitedTo(Session.get('currentBoard'));
- },
- isWorker() {
- const user = Meteor.user();
- if (user) {
- return Meteor.call(Boards.hasWorker(user.memberId));
- } else {
- return false;
- }
- },
- isBoardAdmin() {
- return Meteor.user().isBoardAdmin();
- },
- AtLeastOneOrgWasCreated(){
- let orgs = Org.find({}, {sort: { createdAt: -1 }});
- if(orgs === undefined)
- return false;
- return orgs.count() > 0;
- },
- AtLeastOneTeamWasCreated(){
- let teams = Team.find({}, {sort: { createdAt: -1 }});
- if(teams === undefined)
- return false;
- return teams.count() > 0;
- },
- });
- Template.membersWidget.events({
- 'click .js-member': Popup.open('member'),
- 'click .js-open-board-menu': Popup.open('boardMenu'),
- 'click .js-manage-board-members': Popup.open('addMember'),
- 'click .js-manage-board-addOrg': Popup.open('addBoardOrg'),
- 'click .js-manage-board-addTeam': Popup.open('addBoardTeam'),
- 'click .js-import': Popup.open('boardImportBoard'),
- submit: this.onSubmit,
- 'click .js-import-board': Popup.open('chooseBoardSource'),
- 'click .js-open-archived-board'() {
- Modal.open('archivedBoards');
- },
- 'click .sandstorm-powerbox-request-identity'() {
- window.sandstormRequestIdentity();
- },
- 'click .js-member-invite-accept'() {
- const boardId = Session.get('currentBoard');
- Meteor.user().removeInvite(boardId);
- },
- 'click .js-member-invite-decline'() {
- const boardId = Session.get('currentBoard');
- Meteor.call('quitBoard', boardId, (err, ret) => {
- if (!err && ret) {
- Meteor.user().removeInvite(boardId);
- FlowRouter.go('home');
- }
- });
- },
- });
- BlazeComponent.extendComponent({
- boardId() {
- return Session.get('currentBoard') || Integrations.Const.GLOBAL_WEBHOOK_ID;
- },
- integrations() {
- const boardId = this.boardId();
- return Integrations.find({ boardId: `${boardId}` }).fetch();
- },
- types() {
- return Integrations.Const.WEBHOOK_TYPES;
- },
- integration(cond) {
- const boardId = this.boardId();
- const condition = { boardId, ...cond };
- for (const k in condition) {
- if (!condition[k]) delete condition[k];
- }
- return Integrations.findOne(condition);
- },
- onCreated() {
- this.disabled = new ReactiveVar(false);
- },
- events() {
- return [
- {
- 'click a.flex'(evt) {
- this.disabled.set(!this.disabled.get());
- $(evt.target).toggleClass(CKCLS, this.disabled.get());
- },
- submit(evt) {
- evt.preventDefault();
- const url = evt.target.url.value;
- const boardId = this.boardId();
- let id = null;
- let integration = null;
- const title = evt.target.title.value;
- const token = evt.target.token.value;
- const type = evt.target.type.value;
- const enabled = !this.disabled.get();
- let remove = false;
- const values = {
- url,
- type,
- token,
- title,
- enabled,
- };
- if (evt.target.id) {
- id = evt.target.id.value;
- integration = this.integration({ _id: id });
- remove = !url;
- } else if (url) {
- integration = this.integration({ url, token });
- }
- if (remove) {
- Integrations.remove(integration._id);
- } else if (integration && integration._id) {
- Integrations.update(integration._id, {
- $set: values,
- });
- } else if (url) {
- Integrations.insert({
- ...values,
- userId: Meteor.userId(),
- enabled: true,
- boardId,
- activities: ['all'],
- });
- }
- Popup.back();
- },
- },
- ];
- },
- }).register('outgoingWebhooksPopup');
- BlazeComponent.extendComponent({
- template() {
- return 'chooseBoardSource';
- },
- }).register('chooseBoardSourcePopup');
- BlazeComponent.extendComponent({
- template() {
- return 'exportBoard';
- },
- withApi() {
- return Template.instance().apiEnabled.get();
- },
- exportUrl() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- };
- return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
- },
- exportUrlExcel() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- };
- return FlowRouter.path(
- '/api/boards/:boardId/exportExcel',
- params,
- queryParams,
- );
- },
- exportFilenameExcel() {
- const boardId = Session.get('currentBoard');
- return `export-board-excel-${boardId}.xlsx`;
- },
- exportCsvUrl() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- delimiter: ',',
- };
- return FlowRouter.path(
- '/api/boards/:boardId/export/csv',
- params,
- queryParams,
- );
- },
- exportScsvUrl() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- delimiter: ';',
- };
- return FlowRouter.path(
- '/api/boards/:boardId/export/csv',
- params,
- queryParams,
- );
- },
- exportTsvUrl() {
- const params = {
- boardId: Session.get('currentBoard'),
- };
- const queryParams = {
- authToken: Accounts._storedLoginToken(),
- delimiter: '\t',
- };
- return FlowRouter.path(
- '/api/boards/:boardId/export/csv',
- params,
- queryParams,
- );
- },
- exportJsonFilename() {
- const boardId = Session.get('currentBoard');
- return `export-board-${boardId}.json`;
- },
- exportCsvFilename() {
- const boardId = Session.get('currentBoard');
- return `export-board-${boardId}.csv`;
- },
- exportTsvFilename() {
- const boardId = Session.get('currentBoard');
- return `export-board-${boardId}.tsv`;
- },
- }).register('exportBoardPopup');
- Template.exportBoard.events({
- 'click .html-export-board': async event => {
- event.preventDefault();
- await ExportHtml(Popup)();
- },
- });
- Template.labelsWidget.events({
- 'click .js-label': Popup.open('editLabel'),
- 'click .js-add-label': Popup.open('createLabel'),
- });
- Template.labelsWidget.helpers({
- isBoardAdmin() {
- return Meteor.user().isBoardAdmin();
- },
- });
- // Board members can assign people or labels by drag-dropping elements from the
- // sidebar to the cards on the board. In order to re-initialize the jquery-ui
- // plugin any time a draggable member or label is modified or removed we use a
- // autorun function and register a dependency on the both members and labels
- // fields of the current board document.
- function draggableMembersLabelsWidgets() {
- this.autorun(() => {
- const currentBoardId = Tracker.nonreactive(() => {
- return Session.get('currentBoard');
- });
- Boards.findOne(currentBoardId, {
- fields: {
- members: 1,
- labels: 1,
- },
- });
- Tracker.afterFlush(() => {
- const $draggables = this.$('.js-member,.js-label');
- $draggables.draggable({
- appendTo: 'body',
- helper: 'clone',
- revert: 'invalid',
- revertDuration: 150,
- snap: false,
- snapMode: 'both',
- start() {
- EscapeActions.executeUpTo('popup-back');
- },
- });
- function userIsMember() {
- return Meteor.user() && Meteor.user().isBoardMember();
- }
- this.autorun(() => {
- $draggables.draggable('option', 'disabled', !userIsMember());
- });
- });
- });
- }
- Template.membersWidget.onRendered(draggableMembersLabelsWidgets);
- Template.labelsWidget.onRendered(draggableMembersLabelsWidgets);
- BlazeComponent.extendComponent({
- backgroundColors() {
- return Boards.simpleSchema()._schema.color.allowedValues;
- },
- isSelected() {
- const currentBoard = Utils.getCurrentBoard();
- return currentBoard.color === this.currentData().toString();
- },
- events() {
- return [
- {
- 'click .js-select-background'(evt) {
- const currentBoard = Utils.getCurrentBoard();
- const newColor = this.currentData().toString();
- currentBoard.setColor(newColor);
- evt.preventDefault();
- },
- },
- ];
- },
- }).register('boardChangeColorPopup');
- BlazeComponent.extendComponent({
- events() {
- return [
- {
- submit(event) {
- const currentBoard = Utils.getCurrentBoard();
- const backgroundImageURL = this.find('.js-board-background-image-url').value.trim();
- currentBoard.setBackgroundImageURL(backgroundImageURL);
- Utils.setBackgroundImage();
- Popup.back();
- event.preventDefault();
- },
- 'click .js-remove-background-image'() {
- const currentBoard = Utils.getCurrentBoard();
- currentBoard.setBackgroundImageURL("");
- Popup.back();
- Utils.reload();
- event.preventDefault();
- },
- },
- ];
- },
- }).register('boardChangeBackgroundImagePopup');
- Template.boardChangeBackgroundImagePopup.helpers({
- backgroundImageURL() {
- const currentBoard = Utils.getCurrentBoard();
- return currentBoard.backgroundImageURL;
- },
- });
- BlazeComponent.extendComponent({
- onCreated() {
- this.currentBoard = Utils.getCurrentBoard();
- },
- allowsCardCounterList() {
- return this.currentBoard.allowsCardCounterList;
- },
- allowsBoardMemberList() {
- return this.currentBoard.allowsBoardMemberList;
- },
- events() {
- return [
- {
- 'click .js-field-has-cardcounterlist'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCardCounterList = !this.currentBoard
- .allowsCardCounterList;
- this.currentBoard.setAllowsCardCounterList(
- this.currentBoard.allowsCardCounterList,
- );
- $(`.js-field-has-cardcounterlist ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCardCounterList,
- );
- $('.js-field-has-cardcounterlist').toggleClass(
- CKCLS,
- this.currentBoard.allowsCardCounterList,
- );
- },
- 'click .js-field-has-boardmemberlist'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsBoardMemberList = !this.currentBoard
- .allowsBoardMemberList;
- this.currentBoard.setAllowsBoardMemberList(
- this.currentBoard.allowsBoardMemberList,
- );
- $(`.js-field-has-boardmemberlist ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsBoardMemberList,
- );
- $('.js-field-has-boardmemberlist').toggleClass(
- CKCLS,
- this.currentBoard.allowsBoardMemberList,
- );
- },
- },
- ];
- },
- }).register('boardInfoOnMyBoardsPopup');
- BlazeComponent.extendComponent({
- onCreated() {
- this.currentBoard = Utils.getCurrentBoard();
- },
- allowsSubtasks() {
- return this.currentBoard.allowsSubtasks;
- },
- allowsReceivedDate() {
- return this.currentBoard.allowsReceivedDate;
- },
- isBoardSelected() {
- return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;
- },
- isNullBoardSelected() {
- return (
- this.currentBoard.subtasksDefaultBoardId === null ||
- this.currentBoard.subtasksDefaultBoardId === undefined
- );
- },
- boards() {
- return Boards.find(
- {
- archived: false,
- 'members.userId': Meteor.userId(),
- },
- {
- sort: { sort: 1 /* boards default sorting */ },
- },
- );
- },
- lists() {
- return Lists.find(
- {
- boardId: this.currentBoard._id,
- archived: false,
- },
- {
- sort: ['title'],
- },
- );
- },
- hasLists() {
- return this.lists().count() > 0;
- },
- isListSelected() {
- return this.currentBoard.subtasksDefaultBoardId === this.currentData()._id;
- },
- presentParentTask() {
- let result = this.currentBoard.presentParentTask;
- if (result === null || result === undefined) {
- result = 'no-parent';
- }
- return result;
- },
- events() {
- return [
- {
- 'click .js-field-has-subtasks'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;
- this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);
- $(`.js-field-has-subtasks ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsSubtasks,
- );
- $('.js-field-has-subtasks').toggleClass(
- CKCLS,
- this.currentBoard.allowsSubtasks,
- );
- $('.js-field-deposit-board').prop(
- 'disabled',
- !this.currentBoard.allowsSubtasks,
- );
- },
- 'change .js-field-deposit-board'(evt) {
- let value = evt.target.value;
- if (value === 'null') {
- value = null;
- }
- this.currentBoard.setSubtasksDefaultBoardId(value);
- evt.preventDefault();
- },
- 'change .js-field-deposit-list'(evt) {
- this.currentBoard.setSubtasksDefaultListId(evt.target.value);
- evt.preventDefault();
- },
- 'click .js-field-show-parent-in-minicard'(evt) {
- const value =
- evt.target.id ||
- $(evt.target).parent()[0].id ||
- $(evt.target)
- .parent()[0]
- .parent()[0].id;
- const options = [
- 'prefix-with-full-path',
- 'prefix-with-parent',
- 'subtext-with-full-path',
- 'subtext-with-parent',
- 'no-parent',
- ];
- options.forEach(function(element) {
- if (element !== value) {
- $(`#${element} ${MCB}`).toggleClass(CKCLS, false);
- $(`#${element}`).toggleClass(CKCLS, false);
- }
- });
- $(`#${value} ${MCB}`).toggleClass(CKCLS, true);
- $(`#${value}`).toggleClass(CKCLS, true);
- this.currentBoard.setPresentParentTask(value);
- evt.preventDefault();
- },
- },
- ];
- },
- }).register('boardSubtaskSettingsPopup');
- BlazeComponent.extendComponent({
- onCreated() {
- this.currentBoard = Utils.getCurrentBoard();
- },
- allowsReceivedDate() {
- return this.currentBoard.allowsReceivedDate;
- },
- allowsStartDate() {
- return this.currentBoard.allowsStartDate;
- },
- allowsDueDate() {
- return this.currentBoard.allowsDueDate;
- },
- allowsEndDate() {
- return this.currentBoard.allowsEndDate;
- },
- allowsSubtasks() {
- return this.currentBoard.allowsSubtasks;
- },
- allowsCreator() {
- return (
- this.currentBoard.allowsCreator === null ||
- this.currentBoard.allowsCreator === undefined ||
- this.currentBoard.allowsCreator
- );
- },
- allowsMembers() {
- return this.currentBoard.allowsMembers;
- },
- allowsAssignee() {
- return this.currentBoard.allowsAssignee;
- },
- allowsAssignedBy() {
- return this.currentBoard.allowsAssignedBy;
- },
- allowsRequestedBy() {
- return this.currentBoard.allowsRequestedBy;
- },
- allowsCardSortingByNumber() {
- return this.currentBoard.allowsCardSortingByNumber;
- },
- allowsShowLists() {
- return this.currentBoard.allowsShowLists;
- },
- allowsLabels() {
- return this.currentBoard.allowsLabels;
- },
- allowsChecklists() {
- return this.currentBoard.allowsChecklists;
- },
- allowsAttachments() {
- return this.currentBoard.allowsAttachments;
- },
- allowsComments() {
- return this.currentBoard.allowsComments;
- },
- allowsCardNumber() {
- return this.currentBoard.allowsCardNumber;
- },
- allowsDescriptionTitle() {
- return this.currentBoard.allowsDescriptionTitle;
- },
- allowsDescriptionText() {
- return this.currentBoard.allowsDescriptionText;
- },
- isBoardSelected() {
- return this.currentBoard.dateSettingsDefaultBoardID;
- },
- isNullBoardSelected() {
- return (
- this.currentBoard.dateSettingsDefaultBoardId === null ||
- this.currentBoard.dateSettingsDefaultBoardId === undefined
- );
- },
- boards() {
- return Boards.find(
- {
- archived: false,
- 'members.userId': Meteor.userId(),
- },
- {
- sort: { sort: 1 /* boards default sorting */ },
- },
- );
- },
- lists() {
- return Lists.find(
- {
- boardId: this.currentBoard._id,
- archived: false,
- },
- {
- sort: ['title'],
- },
- );
- },
- hasLists() {
- return this.lists().count() > 0;
- },
- isListSelected() {
- return (
- this.currentBoard.dateSettingsDefaultBoardId === this.currentData()._id
- );
- },
- events() {
- return [
- {
- 'click .js-field-has-receiveddate'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsReceivedDate = !this.currentBoard
- .allowsReceivedDate;
- this.currentBoard.setAllowsReceivedDate(
- this.currentBoard.allowsReceivedDate,
- );
- $(`.js-field-has-receiveddate ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsReceivedDate,
- );
- $('.js-field-has-receiveddate').toggleClass(
- CKCLS,
- this.currentBoard.allowsReceivedDate,
- );
- },
- 'click .js-field-has-startdate'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsStartDate = !this.currentBoard
- .allowsStartDate;
- this.currentBoard.setAllowsStartDate(
- this.currentBoard.allowsStartDate,
- );
- $(`.js-field-has-startdate ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsStartDate,
- );
- $('.js-field-has-startdate').toggleClass(
- CKCLS,
- this.currentBoard.allowsStartDate,
- );
- },
- 'click .js-field-has-enddate'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsEndDate = !this.currentBoard.allowsEndDate;
- this.currentBoard.setAllowsEndDate(this.currentBoard.allowsEndDate);
- $(`.js-field-has-enddate ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsEndDate,
- );
- $('.js-field-has-enddate').toggleClass(
- CKCLS,
- this.currentBoard.allowsEndDate,
- );
- },
- 'click .js-field-has-duedate'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsDueDate = !this.currentBoard.allowsDueDate;
- this.currentBoard.setAllowsDueDate(this.currentBoard.allowsDueDate);
- $(`.js-field-has-duedate ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsDueDate,
- );
- $('.js-field-has-duedate').toggleClass(
- CKCLS,
- this.currentBoard.allowsDueDate,
- );
- },
- 'click .js-field-has-subtasks'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks;
- this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks);
- $(`.js-field-has-subtasks ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsSubtasks,
- );
- $('.js-field-has-subtasks').toggleClass(
- CKCLS,
- this.currentBoard.allowsSubtasks,
- );
- },
- 'click .js-field-has-creator'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCreator = !this.currentBoard.allowsCreator;
- this.currentBoard.setAllowsCreator(this.currentBoard.allowsCreator);
- $(`.js-field-has-creator ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCreator,
- );
- $('.js-field-has-creator').toggleClass(
- CKCLS,
- this.currentBoard.allowsCreator,
- );
- },
- 'click .js-field-has-members'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsMembers = !this.currentBoard.allowsMembers;
- this.currentBoard.setAllowsMembers(this.currentBoard.allowsMembers);
- $(`.js-field-has-members ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsMembers,
- );
- $('.js-field-has-members').toggleClass(
- CKCLS,
- this.currentBoard.allowsMembers,
- );
- },
- 'click .js-field-has-assignee'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsAssignee = !this.currentBoard.allowsAssignee;
- this.currentBoard.setAllowsAssignee(this.currentBoard.allowsAssignee);
- $(`.js-field-has-assignee ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsAssignee,
- );
- $('.js-field-has-assignee').toggleClass(
- CKCLS,
- this.currentBoard.allowsAssignee,
- );
- },
- 'click .js-field-has-assigned-by'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsAssignedBy = !this.currentBoard
- .allowsAssignedBy;
- this.currentBoard.setAllowsAssignedBy(
- this.currentBoard.allowsAssignedBy,
- );
- $(`.js-field-has-assigned-by ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsAssignedBy,
- );
- $('.js-field-has-assigned-by').toggleClass(
- CKCLS,
- this.currentBoard.allowsAssignedBy,
- );
- },
- 'click .js-field-has-requested-by'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsRequestedBy = !this.currentBoard
- .allowsRequestedBy;
- this.currentBoard.setAllowsRequestedBy(
- this.currentBoard.allowsRequestedBy,
- );
- $(`.js-field-has-requested-by ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsRequestedBy,
- );
- $('.js-field-has-requested-by').toggleClass(
- CKCLS,
- this.currentBoard.allowsRequestedBy,
- );
- },
- 'click .js-field-has-card-sorting-by-number'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCardSortingByNumber = !this.currentBoard
- .allowsCardSortingByNumber;
- this.currentBoard.setAllowsCardSortingByNumber(
- this.currentBoard.allowsCardSortingByNumber,
- );
- $(`.js-field-has-card-sorting-by-number ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCardSortingByNumber,
- );
- $('.js-field-has-card-sorting-by-number').toggleClass(
- CKCLS,
- this.currentBoard.allowsCardSortingByNumber,
- );
- },
- 'click .js-field-has-card-show-lists'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsShowLists = !this.currentBoard
- .allowsShowLists;
- this.currentBoard.setAllowsShowLists(
- this.currentBoard.allowsShowLists,
- );
- $(`.js-field-has-card-show-lists ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsShowLists,
- );
- $('.js-field-has-card-show-lists').toggleClass(
- CKCLS,
- this.currentBoard.allowsShowLists,
- );
- },
- 'click .js-field-has-labels'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsLabels = !this.currentBoard.allowsLabels;
- this.currentBoard.setAllowsLabels(this.currentBoard.allowsLabels);
- $(`.js-field-has-labels ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsAssignee,
- );
- $('.js-field-has-labels').toggleClass(
- CKCLS,
- this.currentBoard.allowsLabels,
- );
- },
- 'click .js-field-has-description-title'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsDescriptionTitle = !this.currentBoard
- .allowsDescriptionTitle;
- this.currentBoard.setAllowsDescriptionTitle(
- this.currentBoard.allowsDescriptionTitle,
- );
- $(`.js-field-has-description-title ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionTitle,
- );
- $('.js-field-has-description-title').toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionTitle,
- );
- },
- 'click .js-field-has-card-number'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCardNumber = !this.currentBoard
- .allowsCardNumber;
- this.currentBoard.setAllowsCardNumber(
- this.currentBoard.allowsCardNumber,
- );
- $(`.js-field-has-card-number ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCardNumber,
- );
- $('.js-field-has-card-number').toggleClass(
- CKCLS,
- this.currentBoard.allowsCardNumber,
- );
- },
- 'click .js-field-has-description-text'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsDescriptionText = !this.currentBoard
- .allowsDescriptionText;
- this.currentBoard.setAllowsDescriptionText(
- this.currentBoard.allowsDescriptionText,
- );
- $(`.js-field-has-description-text ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionText,
- );
- $('.js-field-has-description-text').toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionText,
- );
- },
- 'click .js-field-has-checklists'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsChecklists = !this.currentBoard
- .allowsChecklists;
- this.currentBoard.setAllowsChecklists(
- this.currentBoard.allowsChecklists,
- );
- $(`.js-field-has-checklists ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsChecklists,
- );
- $('.js-field-has-checklists').toggleClass(
- CKCLS,
- this.currentBoard.allowsChecklists,
- );
- },
- 'click .js-field-has-attachments'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsAttachments = !this.currentBoard
- .allowsAttachments;
- this.currentBoard.setAllowsAttachments(
- this.currentBoard.allowsAttachments,
- );
- $(`.js-field-has-attachments ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsAttachments,
- );
- $('.js-field-has-attachments').toggleClass(
- CKCLS,
- this.currentBoard.allowsAttachments,
- );
- },
- 'click .js-field-has-comments'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsComments = !this.currentBoard.allowsComments;
- this.currentBoard.setAllowsComments(this.currentBoard.allowsComments);
- $(`.js-field-has-comments ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsComments,
- );
- $('.js-field-has-comments').toggleClass(
- CKCLS,
- this.currentBoard.allowsComments,
- );
- },
- 'click .js-field-has-activities'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsActivities = !this.currentBoard
- .allowsActivities;
- this.currentBoard.setAllowsActivities(
- this.currentBoard.allowsActivities,
- );
- $(`.js-field-has-activities ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsActivities,
- );
- $('.js-field-has-activities').toggleClass(
- CKCLS,
- this.currentBoard.allowsActivities,
- );
- },
- },
- ];
- },
- }).register('boardCardSettingsPopup');
- BlazeComponent.extendComponent({
- onCreated() {
- this.currentBoard = Utils.getCurrentBoard();
- },
- allowsDescriptionTextOnMinicard() {
- return this.currentBoard.allowsDescriptionTextOnMinicard;
- },
- allowsCoverAttachmentOnMinicard() {
- return this.currentBoard.allowsCoverAttachmentOnMinicard;
- },
- allowsBadgeAttachmentOnMinicard() {
- return this.currentBoard.allowsBadgeAttachmentOnMinicard;
- },
- allowsCardSortingByNumberOnMinicard() {
- return this.currentBoard.allowsCardSortingByNumberOnMinicard;
- },
- lists() {
- return Lists.find(
- {
- boardId: this.currentBoard._id,
- archived: false,
- },
- {
- sort: ['title'],
- },
- );
- },
- hasLists() {
- return this.lists().count() > 0;
- },
- isListSelected() {
- return (
- this.currentBoard.dateSettingsDefaultBoardId === this.currentData()._id
- );
- },
- events() {
- return [
- {
- 'click .js-field-has-description-text-on-minicard'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsDescriptionTextOnMinicard = !this.currentBoard
- .allowsDescriptionTextOnMinicard;
- this.currentBoard.setallowsDescriptionTextOnMinicard(
- this.currentBoard.allowsDescriptionTextOnMinicard,
- );
- $(`.js-field-has-description-text-on-minicard ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionTextOnMinicard,
- );
- $('.js-field-has-description-text-on-minicard').toggleClass(
- CKCLS,
- this.currentBoard.allowsDescriptionTextOnMinicard,
- );
- },
- 'click .js-field-has-cover-attachment-on-minicard'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCoverAttachmentOnMinicard = !this.currentBoard
- .allowsCoverAttachmentOnMinicard;
- this.currentBoard.setallowsCoverAttachmentOnMinicard(
- this.currentBoard.allowsCoverAttachmentOnMinicard,
- );
- $(`.js-field-has-cover-attachment-on-minicard ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCoverAttachmentOnMinicard,
- );
- $('.js-field-has-cover-attachment-on-minicard').toggleClass(
- CKCLS,
- this.currentBoard.allowsCoverAttachmentOnMinicard,
- );
- },
- 'click .js-field-has-badge-attachment-on-minicard'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsBadgeAttachmentOnMinicard = !this.currentBoard
- .allowsBadgeAttachmentOnMinicard;
- this.currentBoard.setallowsBadgeAttachmentOnMinicard(
- this.currentBoard.allowsBadgeAttachmentOnMinicard,
- );
- $(`.js-field-has-badge-attachment-on-minicard ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsBadgeAttachmentOnMinicard,
- );
- $('.js-field-has-badge-attachment-on-minicard').toggleClass(
- CKCLS,
- this.currentBoard.allowsBadgeAttachmentOnMinicard,
- );
- },
- 'click .js-field-has-card-sorting-by-number-on-minicard'(evt) {
- evt.preventDefault();
- this.currentBoard.allowsCardSortingByNumberOnMinicard = !this.currentBoard
- .allowsCardSortingByNumberOnMinicard;
- this.currentBoard.setallowsCardSortingByNumberOnMinicard(
- this.currentBoard.allowsCardSortingByNumberOnMinicard,
- );
- $(`.js-field-has-card-sorting-by-number-on-minicard ${MCB}`).toggleClass(
- CKCLS,
- this.currentBoard.allowsCardSortingByNumberOnMinicard,
- );
- $('.js-field-has-card-sorting-by-number-on-minicard').toggleClass(
- CKCLS,
- this.currentBoard.allowsCardSortingByNumberOnMinicard,
- );
- },
- },
- ];
- },
- }).register('boardMinicardSettingsPopup');
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- },
- onRendered() {
- this.find('.js-search-member input').focus();
- this.setLoading(false);
- },
- isBoardMember() {
- const userId = this.currentData().__originalId;
- const user = Users.findOne(userId);
- return user && user.isBoardMember();
- },
- isValidEmail(email) {
- return SimpleSchema.RegEx.Email.test(email);
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- inviteUser(idNameEmail) {
- const boardId = Session.get('currentBoard');
- this.setLoading(true);
- const self = this;
- Meteor.call('inviteUserToBoard', idNameEmail, boardId, (err, ret) => {
- self.setLoading(false);
- if (err) self.setError(err.error);
- else if (ret.email) self.setError('email-sent');
- else Popup.back();
- });
- },
- events() {
- return [
- {
- 'keyup input'() {
- this.setError('');
- },
- 'click .js-select-member'() {
- const userId = this.currentData().__originalId;
- const currentBoard = Utils.getCurrentBoard();
- if (!currentBoard.hasMember(userId)) {
- this.inviteUser(userId);
- }
- },
- 'click .js-email-invite'() {
- const idNameEmail = $('.js-search-member input').val();
- if (idNameEmail.indexOf('@') < 0 || this.isValidEmail(idNameEmail)) {
- this.inviteUser(idNameEmail);
- } else this.setError('email-invalid');
- },
- },
- ];
- },
- }).register('addMemberPopup');
- Template.addMemberPopup.helpers({
- searchIndex: () => UserSearchIndex,
- })
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- this.findOrgsOptions = new ReactiveVar({});
- this.page = new ReactiveVar(1);
- this.autorun(() => {
- const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
- });
- },
- onRendered() {
- this.setLoading(false);
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- events() {
- return [
- {
- 'keyup input'() {
- this.setError('');
- },
- 'change #jsBoardOrgs'() {
- let currentBoard = Utils.getCurrentBoard();
- let selectElt = document.getElementById("jsBoardOrgs");
- let selectedOrgId = selectElt.options[selectElt.selectedIndex].value;
- let selectedOrgDisplayName = selectElt.options[selectElt.selectedIndex].text;
- let boardOrganizations = [];
- if(currentBoard.orgs !== undefined){
- for(let i = 0; i < currentBoard.orgs.length; i++){
- boardOrganizations.push(currentBoard.orgs[i]);
- }
- }
- if(!boardOrganizations.some((org) => org.orgDisplayName == selectedOrgDisplayName)){
- boardOrganizations.push({
- "orgId": selectedOrgId,
- "orgDisplayName": selectedOrgDisplayName,
- "isActive" : true,
- })
- if (selectedOrgId != "-1") {
- Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);
- }
- }
- Popup.back();
- },
- },
- ];
- },
- }).register('addBoardOrgPopup');
- Template.addBoardOrgPopup.helpers({
- orgsDatas() {
- let orgs = Org.find({}, {sort: { orgDisplayName: 1 }});
- return orgs;
- },
- });
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- this.findOrgsOptions = new ReactiveVar({});
- this.page = new ReactiveVar(1);
- this.autorun(() => {
- const limitOrgs = this.page.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('org', this.findOrgsOptions.get(), limitOrgs, () => {});
- });
- },
- onRendered() {
- this.setLoading(false);
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- events() {
- return [
- {
- 'keyup input'() {
- this.setError('');
- },
- 'click #leaveBoardBtn'(){
- let stringOrgId = document.getElementById('hideOrgId').value;
- let currentBoard = Utils.getCurrentBoard();
- let boardOrganizations = [];
- if(currentBoard.orgs !== undefined){
- for(let i = 0; i < currentBoard.orgs.length; i++){
- if(currentBoard.orgs[i].orgId != stringOrgId){
- boardOrganizations.push(currentBoard.orgs[i]);
- }
- }
- }
- Meteor.call('setBoardOrgs', boardOrganizations, currentBoard._id);
- Popup.back();
- },
- 'click #cancelLeaveBoardBtn'(){
- Popup.back();
- },
- },
- ];
- },
- }).register('removeBoardOrgPopup');
- Template.removeBoardOrgPopup.helpers({
- org() {
- return Org.findOne(this.orgId);
- },
- });
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- this.findOrgsOptions = new ReactiveVar({});
- this.page = new ReactiveVar(1);
- this.autorun(() => {
- const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});
- });
- this.findUsersOptions = new ReactiveVar({});
- this.userPage = new ReactiveVar(1);
- this.autorun(() => {
- const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});
- });
- },
- onRendered() {
- this.setLoading(false);
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- events() {
- return [
- {
- 'keyup input'() {
- this.setError('');
- },
- 'change #jsBoardTeams'() {
- let currentBoard = Utils.getCurrentBoard();
- let selectElt = document.getElementById("jsBoardTeams");
- let selectedTeamId = selectElt.options[selectElt.selectedIndex].value;
- let selectedTeamDisplayName = selectElt.options[selectElt.selectedIndex].text;
- let boardTeams = [];
- if(currentBoard.teams !== undefined){
- for(let i = 0; i < currentBoard.teams.length; i++){
- boardTeams.push(currentBoard.teams[i]);
- }
- }
- if(!boardTeams.some((team) => team.teamDisplayName == selectedTeamDisplayName)){
- boardTeams.push({
- "teamId": selectedTeamId,
- "teamDisplayName": selectedTeamDisplayName,
- "isActive" : true,
- })
- if (selectedTeamId != "-1") {
- let members = currentBoard.members;
- let query = {
- "teams.teamId": { $in: boardTeams.map(t => t.teamId) },
- };
- const boardTeamUsers = Users.find(query, {
- sort: { sort: 1 },
- });
- if(boardTeams !== undefined && boardTeams.length > 0){
- let index;
- if(boardTeamUsers && boardTeamUsers.count() > 0){
- boardTeamUsers.forEach((u) => {
- index = members.findIndex(function(m){ return m.userId == u._id});
- if(index == -1){
- members.push({
- "isActive": true,
- "isAdmin": u.isAdmin !== undefined ? u.isAdmin : false,
- "isCommentOnly" : false,
- "isNoComments" : false,
- "userId": u._id,
- });
- }
- });
- }
- }
- Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);
- }
- }
- Popup.back();
- },
- },
- ];
- },
- }).register('addBoardTeamPopup');
- Template.addBoardTeamPopup.helpers({
- teamsDatas() {
- let teams = Team.find({}, {sort: { teamDisplayName: 1 }});
- return teams;
- },
- });
- BlazeComponent.extendComponent({
- onCreated() {
- this.error = new ReactiveVar('');
- this.loading = new ReactiveVar(false);
- this.findOrgsOptions = new ReactiveVar({});
- this.page = new ReactiveVar(1);
- this.autorun(() => {
- const limitTeams = this.page.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('team', this.findOrgsOptions.get(), limitTeams, () => {});
- });
- this.findUsersOptions = new ReactiveVar({});
- this.userPage = new ReactiveVar(1);
- this.autorun(() => {
- const limitUsers = this.userPage.get() * Number.MAX_SAFE_INTEGER;
- this.subscribe('people', this.findUsersOptions.get(), limitUsers, () => {});
- });
- },
- onRendered() {
- this.setLoading(false);
- },
- setError(error) {
- this.error.set(error);
- },
- setLoading(w) {
- this.loading.set(w);
- },
- isLoading() {
- return this.loading.get();
- },
- events() {
- return [
- {
- 'keyup input'() {
- this.setError('');
- },
- 'click #leaveBoardTeamBtn'(){
- let stringTeamId = document.getElementById('hideTeamId').value;
- let currentBoard = Utils.getCurrentBoard();
- let boardTeams = [];
- if(currentBoard.teams !== undefined){
- for(let i = 0; i < currentBoard.teams.length; i++){
- if(currentBoard.teams[i].teamId != stringTeamId){
- boardTeams.push(currentBoard.teams[i]);
- }
- }
- }
- let members = currentBoard.members;
- let query = {
- "teams.teamId": stringTeamId
- };
- const boardTeamUsers = Users.find(query, {
- sort: { sort: 1 },
- });
- if(currentBoard.teams !== undefined && currentBoard.teams.length > 0){
- let index;
- if(boardTeamUsers && boardTeamUsers.count() > 0){
- boardTeamUsers.forEach((u) => {
- index = members.findIndex(function(m){ return m.userId == u._id});
- if(index !== -1 && (u.isAdmin === undefined || u.isAdmin == false)){
- members.splice(index, 1);
- }
- });
- }
- }
- Meteor.call('setBoardTeams', boardTeams, members, currentBoard._id);
- Popup.back();
- },
- 'click #cancelLeaveBoardTeamBtn'(){
- Popup.back();
- },
- },
- ];
- },
- }).register('removeBoardTeamPopup');
- Template.removeBoardTeamPopup.helpers({
- team() {
- return Team.findOne(this.teamId);
- },
- });
- Template.changePermissionsPopup.events({
- 'click .js-set-admin, click .js-set-normal, click .js-set-no-comments, click .js-set-comment-only, click .js-set-worker'(
- event,
- ) {
- const currentBoard = Utils.getCurrentBoard();
- const memberId = this.userId;
- const isAdmin = $(event.currentTarget).hasClass('js-set-admin');
- const isCommentOnly = $(event.currentTarget).hasClass(
- 'js-set-comment-only',
- );
- const isNoComments = $(event.currentTarget).hasClass('js-set-no-comments');
- const isWorker = $(event.currentTarget).hasClass('js-set-worker');
- currentBoard.setMemberPermission(
- memberId,
- isAdmin,
- isNoComments,
- isCommentOnly,
- isWorker,
- );
- Popup.back(1);
- },
- });
- Template.changePermissionsPopup.helpers({
- isAdmin() {
- const currentBoard = Utils.getCurrentBoard();
- return currentBoard.hasAdmin(this.userId);
- },
- isNormal() {
- const currentBoard = Utils.getCurrentBoard();
- return (
- !currentBoard.hasAdmin(this.userId) &&
- !currentBoard.hasNoComments(this.userId) &&
- !currentBoard.hasCommentOnly(this.userId) &&
- !currentBoard.hasWorker(this.userId)
- );
- },
- isNoComments() {
- const currentBoard = Utils.getCurrentBoard();
- return (
- !currentBoard.hasAdmin(this.userId) &&
- currentBoard.hasNoComments(this.userId)
- );
- },
- isCommentOnly() {
- const currentBoard = Utils.getCurrentBoard();
- return (
- !currentBoard.hasAdmin(this.userId) &&
- currentBoard.hasCommentOnly(this.userId)
- );
- },
- isWorker() {
- const currentBoard = Utils.getCurrentBoard();
- return (
- !currentBoard.hasAdmin(this.userId) && currentBoard.hasWorker(this.userId)
- );
- },
- isLastAdmin() {
- const currentBoard = Utils.getCurrentBoard();
- return (
- currentBoard.hasAdmin(this.userId) && currentBoard.activeAdmins() === 1
- );
- },
- });
|