diff options
Diffstat (limited to 'client/components')
-rw-r--r-- | client/components/boards/boardBody.js | 76 | ||||
-rw-r--r-- | client/components/main/layouts.jade | 6 | ||||
-rw-r--r-- | client/components/main/layouts.js | 132 | ||||
-rw-r--r-- | client/components/settings/settingBody.jade | 19 | ||||
-rw-r--r-- | client/components/settings/settingBody.js | 40 | ||||
-rw-r--r-- | client/components/swimlanes/swimlanes.styl | 3 |
6 files changed, 203 insertions, 73 deletions
diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 2de8777a..9105e624 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -1,5 +1,6 @@ const subManager = new SubsManager(); const { calculateIndex, enableClickOnTouch } = Utils; +const swimlaneWhileSortingHeight = 150; BlazeComponent.extendComponent({ onCreated() { @@ -74,21 +75,64 @@ BlazeComponent.extendComponent({ $swimlanesDom.sortable({ tolerance: 'pointer', appendTo: '.board-canvas', - helper: 'clone', + helper(evt, item) { + const helper = $(`<div class="swimlane" + style="flex-direction: column; + height: ${swimlaneWhileSortingHeight}px; + width: $(boardComponent.width)px; + overflow: hidden;"/>`); + helper.append(item.clone()); + // Also grab the list of lists of cards + const list = item.next(); + helper.append(list.clone()); + return helper; + }, handle: '.js-swimlane-header', - items: '.js-swimlane:not(.placeholder)', + items: '.swimlane:not(.placeholder)', placeholder: 'swimlane placeholder', distance: 7, start(evt, ui) { + const listDom = ui.placeholder.next('.js-swimlane'); + const parentOffset = ui.item.parent().offset(); + ui.placeholder.height(ui.helper.height()); EscapeActions.executeUpTo('popup-close'); + listDom.addClass('moving-swimlane'); boardComponent.setIsDragging(true); + + ui.placeholder.insertAfter(ui.placeholder.next()); + boardComponent.origPlaceholderIndex = ui.placeholder.index(); + + // resize all swimlanes + headers to be a total of 150 px per row + // this could be achieved by setIsDragging(true) but we want immediate + // result + ui.item.siblings('.js-swimlane').css('height', `${swimlaneWhileSortingHeight - 26}px`); + + // set the new scroll height after the resize and insertion of + // the placeholder. We want the element under the cursor to stay + // at the same place on the screen + ui.item.parent().get(0).scrollTop = ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; + }, + beforeStop(evt, ui) { + const parentOffset = ui.item.parent().offset(); + const siblings = ui.item.siblings('.js-swimlane'); + siblings.css('height', ''); + + // compute the new scroll height after the resize and removal of + // the placeholder + const scrollTop = ui.placeholder.get(0).offsetTop + parentOffset.top - evt.pageY; + + // then reset the original view of the swimlane + siblings.removeClass('moving-swimlane'); + + // and apply the computed scrollheight + ui.item.parent().get(0).scrollTop = scrollTop; }, stop(evt, ui) { // To attribute the new index number, we need to get the DOM element // of the previous and the following card -- if any. - const prevSwimlaneDom = ui.item.prev('.js-swimlane').get(0); - const nextSwimlaneDom = ui.item.next('.js-swimlane').get(0); + const prevSwimlaneDom = ui.item.prevAll('.js-swimlane').get(0); + const nextSwimlaneDom = ui.item.nextAll('.js-swimlane').get(0); const sortIndex = calculateIndex(prevSwimlaneDom, nextSwimlaneDom, 1); $swimlanesDom.sortable('cancel'); @@ -103,6 +147,30 @@ BlazeComponent.extendComponent({ boardComponent.setIsDragging(false); }, + sort(evt, ui) { + // get the mouse position in the sortable + const parentOffset = ui.item.parent().offset(); + const cursorY = evt.pageY - parentOffset.top + ui.item.parent().scrollTop(); + + // compute the intended index of the placeholder (we need to skip the + // slots between the headers and the list of cards) + const newplaceholderIndex = Math.floor(cursorY / swimlaneWhileSortingHeight); + let destPlaceholderIndex = (newplaceholderIndex + 1) * 2; + + // if we are scrolling far away from the bottom of the list + if (destPlaceholderIndex >= ui.item.parent().get(0).childElementCount) { + destPlaceholderIndex = ui.item.parent().get(0).childElementCount - 1; + } + + // update the placeholder position in the DOM tree + if (destPlaceholderIndex !== ui.placeholder.index()) { + if (destPlaceholderIndex < boardComponent.origPlaceholderIndex) { + ui.placeholder.insertBefore(ui.placeholder.siblings().slice(destPlaceholderIndex - 2, destPlaceholderIndex - 1)); + } else { + ui.placeholder.insertAfter(ui.placeholder.siblings().slice(destPlaceholderIndex - 1, destPlaceholderIndex)); + } + } + }, }); // ugly touch event hotfix diff --git a/client/components/main/layouts.jade b/client/components/main/layouts.jade index 55ee2686..a6115ec1 100644 --- a/client/components/main/layouts.jade +++ b/client/components/main/layouts.jade @@ -23,10 +23,8 @@ template(name="userFormsLayout") br section.auth-dialog +Template.dynamic(template=content) - +connectionMethod - if isCas - .at-form - button#cas(class='at-btn submit' type='submit') {{casSignInLabel}} + if currentSetting.displayAuthenticationMethod + +connectionMethod div.at-form-lang select.select-lang.js-userform-set-language each languages diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js index a50d167e..6f7c914a 100644 --- a/client/components/main/layouts.js +++ b/client/components/main/layouts.js @@ -20,13 +20,19 @@ const validator = { }, }; -Template.userFormsLayout.onCreated(() => { - Meteor.subscribe('setting'); - +Template.userFormsLayout.onCreated(function() { + const instance = this; + instance.currentSetting = new ReactiveVar(); + + Meteor.subscribe('setting', { + onReady() { + instance.currentSetting.set(Settings.findOne()); + return this.stop(); + }, + }); }); Template.userFormsLayout.onRendered(() => { - AccountsTemplates.state.form.keys = new Proxy(AccountsTemplates.state.form.keys, validator); const i18nTag = navigator.language; @@ -37,12 +43,10 @@ Template.userFormsLayout.onRendered(() => { }); Template.userFormsLayout.helpers({ - currentSetting() { - return Settings.findOne(); + return Template.instance().currentSetting.get(); }, - afterBodyStart() { return currentSetting.customHTMLafterBodyStart; }, @@ -75,17 +79,6 @@ Template.userFormsLayout.helpers({ const curLang = T9n.getLanguage() || 'en'; return t9nTag === curLang; }, -/* - isCas() { - return Meteor.settings.public && - Meteor.settings.public.cas && - Meteor.settings.public.cas.loginUrl; - }, - - casSignInLabel() { - return TAPi18n.__('casSignIn', {}, T9n.getLanguage() || 'en'); - }, -*/ }); Template.userFormsLayout.events({ @@ -94,55 +87,74 @@ Template.userFormsLayout.events({ T9n.setLanguage(i18nTagToT9n(i18nTag)); evt.preventDefault(); }, - 'click button#cas'() { + 'click #at-btn'(event, instance) { + if (FlowRouter.getRouteName() === 'atSignIn') { + authentication(event, instance); + } + }, +}); + +Template.defaultLayout.events({ + 'click .js-close-modal': () => { + Modal.close(); + }, +}); + +async function authentication(event, instance) { + const match = $('#at-field-username_and_email').val(); + const password = $('#at-field-password').val(); + + if (!match || !password) return; + + const result = await getAuthenticationMethod(instance.currentSetting.get(), match); + + if (result === 'password') return; + + // Stop submit #at-pwd-form + event.preventDefault(); + event.stopImmediatePropagation(); + + switch (result) { + case 'ldap': + Meteor.loginWithLDAP(match, password, function() { + FlowRouter.go('/'); + }); + break; + + case 'cas': Meteor.loginWithCas(function() { - if (FlowRouter.getRouteName() === 'atSignIn') { - FlowRouter.go('/'); - } + FlowRouter.go('/'); }); - }, - 'click #at-btn'(event) { - /* All authentication method can be managed/called here. - !! DON'T FORGET to correctly fill the fields of the user during its creation if necessary authenticationMethod : String !! - */ - const authenticationMethodSelected = $('.select-authentication').val(); - // Local account - if (authenticationMethodSelected === 'password') { - return; - } + break; - // Stop submit #at-pwd-form - event.preventDefault(); - event.stopImmediatePropagation(); + default: + break; + } +} - const email = $('#at-field-username_and_email').val(); - const password = $('#at-field-password').val(); +function getAuthenticationMethod({displayAuthenticationMethod, defaultAuthenticationMethod}, match) { + if (displayAuthenticationMethod) { + return $('.select-authentication').val(); + } + return getUserAuthenticationMethod(defaultAuthenticationMethod, match); +} - // Ldap account - if (authenticationMethodSelected === 'ldap') { - // Check if the user can use the ldap connection - Meteor.subscribe('user-authenticationMethod', email, { +function getUserAuthenticationMethod(defaultAuthenticationMethod, match) { + return new Promise((resolve) => { + try { + Meteor.subscribe('user-authenticationMethod', match, { onReady() { const user = Users.findOne(); - if (user === undefined || user.authenticationMethod === 'ldap') { - // Use the ldap connection package - Meteor.loginWithLDAP(email, password, function(error) { - if (!error) { - // Connection - return FlowRouter.go('/'); - } - return error; - }); - } - return this.stop(); + + const authenticationMethod = user + ? user.authenticationMethod + : defaultAuthenticationMethod; + + resolve(authenticationMethod); }, }); + } catch(error) { + resolve(defaultAuthenticationMethod); } - }, -}); - -Template.defaultLayout.events({ - 'click .js-close-modal': () => { - Modal.close(); - }, -}); + }); +} diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade index 153649fc..220dbb50 100644 --- a/client/components/settings/settingBody.jade +++ b/client/components/settings/settingBody.jade @@ -142,6 +142,16 @@ template(name='layoutSettings') input.form-control#hide-logo(type="radio" name="hideLogo" value="false" checked="{{#unless currentSetting.hideLogo}}checked{{/unless}}") span {{_ 'no'}} li.layout-form + .title {{_ 'display-authentication-method'}} + .form-group.flex + input.form-control#display-authentication-method(type="radio" name="displayAuthenticationMethod" value="true" checked="{{#if currentSetting.displayAuthenticationMethod}}checked{{/if}}") + span {{_ 'yes'}} + input.form-control#display-authentication-method(type="radio" name="displayAuthenticationMethod" value="false" checked="{{#unless currentSetting.displayAuthenticationMethod}}checked{{/unless}}") + span {{_ 'no'}} + li.layout-form + .title {{_ 'default-authentication-method'}} + +selectAuthenticationMethod(authenticationMethod=currentSetting.defaultAuthenticationMethod) + li.layout-form .title {{_ 'custom-product-name'}} .form-group input.form-control#product-name(type="text", placeholder="Wekan" value="{{currentSetting.productName}}") @@ -153,3 +163,12 @@ template(name='layoutSettings') textarea#customHTMLbeforeBodyEnd.form-control= currentSetting.customHTMLbeforeBodyEnd li button.js-save-layout.primary {{_ 'save'}} + + +template(name='selectAuthenticationMethod') + select#defaultAuthenticationMethod + each authentications + if isSelected value + option(value="{{value}}" selected) {{_ value}} + else + option(value="{{value}}") {{_ value}}
\ No newline at end of file diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js index 4f07c84c..2f58d551 100644 --- a/client/components/settings/settingBody.js +++ b/client/components/settings/settingBody.js @@ -62,6 +62,9 @@ BlazeComponent.extendComponent({ toggleHideLogo() { $('#hide-logo').toggleClass('is-checked'); }, + toggleDisplayAuthenticationMethod() { + $('#display-authentication-method').toggleClass('is-checked'); + }, switchMenu(event) { const target = $(event.target); if (!target.hasClass('active')) { @@ -140,17 +143,20 @@ BlazeComponent.extendComponent({ const productName = $('#product-name').val().trim(); const hideLogoChange = ($('input[name=hideLogo]:checked').val() === 'true'); + const displayAuthenticationMethod = ($('input[name=displayAuthenticationMethod]:checked').val() === 'true'); + const defaultAuthenticationMethod = $('#defaultAuthenticationMethod').val(); const customHTMLafterBodyStart = $('#customHTMLafterBodyStart').val().trim(); const customHTMLbeforeBodyEnd = $('#customHTMLbeforeBodyEnd').val().trim(); try { - Settings.update(Settings.findOne()._id, { $set: { productName, hideLogo: hideLogoChange, customHTMLafterBodyStart, customHTMLbeforeBodyEnd, + displayAuthenticationMethod, + defaultAuthenticationMethod, }, }); } catch (e) { @@ -165,17 +171,14 @@ BlazeComponent.extendComponent({ sendSMTPTestEmail() { Meteor.call('sendSMTPTestEmail', (err, ret) => { - if (!err && ret) { /* eslint-disable no-console */ + if (!err && ret) { const message = `${TAPi18n.__(ret.message)}: ${ret.email}`; - console.log(message); alert(message); } else { const reason = err.reason || ''; const message = `${TAPi18n.__(err.error)}\n${reason}`; - console.log(message, err); alert(message); } - /* eslint-enable no-console */ }); }, @@ -190,6 +193,7 @@ BlazeComponent.extendComponent({ 'click button.js-send-smtp-test-email': this.sendSMTPTestEmail, 'click a.js-toggle-hide-logo': this.toggleHideLogo, 'click button.js-save-layout': this.saveLayout, + 'click a.js-toggle-display-authentication-method': this.toggleDisplayAuthenticationMethod, }]; }, }).register('setting'); @@ -262,3 +266,29 @@ BlazeComponent.extendComponent({ }]; }, }).register('announcementSettings'); + + +Template.selectAuthenticationMethod.onCreated(function() { + this.authenticationMethods = new ReactiveVar([]); + + Meteor.call('getAuthenticationsEnabled', (_, result) => { + if (result) { + // TODO : add a management of different languages + // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) + this.authenticationMethods.set([ + {value: 'password'}, + // Gets only the authentication methods availables + ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})), + ]); + } + }); +}); + +Template.selectAuthenticationMethod.helpers({ + authentications() { + return Template.instance().authenticationMethods.get(); + }, + isSelected(match) { + return Template.instance().data.authenticationMethod === match; + }, +}); diff --git a/client/components/swimlanes/swimlanes.styl b/client/components/swimlanes/swimlanes.styl index 77a7a413..1056e1e3 100644 --- a/client/components/swimlanes/swimlanes.styl +++ b/client/components/swimlanes/swimlanes.styl @@ -53,6 +53,9 @@ .list-group height: 100% +.moving-swimlane + display: none + swimlane-color(background, color...) background: background !important if color |