2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-return-assign,
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
'use strict'
|
2016-06-14 09:57:39 +02:00
|
|
|
|
2018-11-19 16:17:49 +01:00
|
|
|
/**
|
|
|
|
* This directive will allow to select a member.
|
|
|
|
* Please surround it with a ng-if directive to prevent it from being used by a non-admin user.
|
|
|
|
* The resulting member will be set into the parent $scope (=> $scope.ctrl.member).
|
|
|
|
* The directive takes an optional parameter "subscription" as a "boolean string" that will filter the user
|
|
|
|
* which have a valid running subscription or not.
|
|
|
|
* Usage: <select-member [subscription="false|true"]></select-member>
|
|
|
|
*/
|
2018-10-25 16:50:16 +02:00
|
|
|
Application.Directives.directive('selectMember', [ 'Diacritics', 'Member', (Diacritics, Member) =>
|
|
|
|
({
|
|
|
|
restrict: 'E',
|
|
|
|
templateUrl: '<%= asset_path "shared/_member_select.html" %>',
|
2018-10-25 16:51:20 +02:00
|
|
|
link (scope, element, attributes) {
|
|
|
|
return scope.autoCompleteName = function (nameLookup) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (!nameLookup) {
|
2018-10-25 16:51:20 +02:00
|
|
|
return
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
scope.isLoadingMembers = true
|
|
|
|
const asciiName = Diacritics.remove(nameLookup)
|
2016-06-14 09:57:39 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
const q = { query: asciiName }
|
2018-10-25 16:50:16 +02:00
|
|
|
if (attributes.subscription) {
|
2018-10-25 16:51:20 +02:00
|
|
|
q['subscription'] = attributes.subscription
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2016-06-14 09:57:39 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
return Member.search(q, function (users) {
|
|
|
|
scope.matchingMembers = users
|
|
|
|
return scope.isLoadingMembers = false
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
, error => console.error(error))
|
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2016-06-14 09:57:39 +02:00
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
])
|