initial github commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import ApplicationAdapter from './application'
|
||||
import config from 'ember-get-config'
|
||||
|
||||
export default ApplicationAdapter.extend
|
||||
urlForQueryRecord: (query) ->
|
||||
if query.me
|
||||
delete query.me
|
||||
return config.userMeEndpoint || "#{config.apiHost}#{config.rootURL}users/me"
|
||||
@_super arguments...
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import Base from 'ember-simple-auth/authenticators/devise'
|
||||
import config from 'ember-get-config'
|
||||
|
||||
export default Base.extend
|
||||
serverTokenEndpoint: config.serverTokenEndpoint || "#{config.apiHost}/users/sign_in"
|
||||
@@ -0,0 +1,3 @@
|
||||
import Devise from 'ember-simple-auth/authorizers/devise'
|
||||
|
||||
export default Devise.extend {}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/collapsible-content';
|
||||
@@ -0,0 +1,15 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
classNames: ['section']
|
||||
active: false
|
||||
isFirst: false
|
||||
classNameBindings: ['active']
|
||||
didInsertElement: ->
|
||||
@_super arguments...
|
||||
Ember.run.scheduleOnce 'afterRender', => @get('register')(this)
|
||||
|
||||
willDestroyElement: ->
|
||||
@get('unregister')(this)
|
||||
@_super arguments...
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
css_type: 'semantic'
|
||||
classNameBindings: ['css_type_classes']
|
||||
css_type_classes: Ember.computed 'css_type', ->
|
||||
switch @get('css_type')
|
||||
when 'semantic' then 'dunlop-breadcrumbs ui container bottom attached block header'
|
||||
else 'dunlop-breadcrumbs'
|
||||
|
||||
items: Ember.computed -> Ember.A([]) # emberx-select example
|
||||
|
||||
actions:
|
||||
registerItem: (item) ->
|
||||
item.set('isFirst', true) unless @get('items.length')
|
||||
@get('items').push(item)
|
||||
|
||||
unregisterItem: (item) ->
|
||||
@get('items').removeObject(item)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/editable-attribute';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/error-handling'
|
||||
@@ -0,0 +1,11 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
#layoutName: 'components/flash-message'
|
||||
classNames: ['flash-message']
|
||||
classNameBindings: ['message:active']
|
||||
message: Ember.computed.alias 'globals.flash_message'
|
||||
click: -> @set 'globals.flash_message', ''
|
||||
inactivator: Ember.observer 'message', ->
|
||||
if @get('message')
|
||||
Ember.run.later((=> @set 'globals.flash_message', ''), 4000)
|
||||
@@ -0,0 +1,43 @@
|
||||
import Ember from 'ember'
|
||||
#import config from '../config/environment'
|
||||
|
||||
export default Ember.Component.extend
|
||||
session: Ember.inject.service('session')
|
||||
identification: ''
|
||||
password: ''
|
||||
actions:
|
||||
submitLogin: ->
|
||||
unless email=@get('identification')
|
||||
return @$('.login-email').focus()
|
||||
unless password=@get('password')
|
||||
return @$('.login-password').focus()
|
||||
|
||||
## STRATEGY 1 HARD TOKEN FROM API
|
||||
#uri = "#{config.apiHost}/#{config.apiNamespace}/users/obtain_token"
|
||||
#Ember.$.post uri, email: email, password: password, (result) =>
|
||||
# result = JSON.parse(result) if typeof result is 'string'
|
||||
# unless result.valid
|
||||
# @set 'globals.flash_message', 'Invalid login'
|
||||
# return false
|
||||
# localStorage.setItem 'authentication_token', result.authentication_token
|
||||
# localStorage.setItem 'user_id', result.user_id
|
||||
# @get('router').transitionTo('index').then (index_route) ->
|
||||
# # do not set on globals of current route, since that one will be 'destroyed' in trasition
|
||||
# index_route.store.findRecord('user', result.user_id).then (current_user) -> index_route.set('router.globals.current_user', current_user)
|
||||
|
||||
## STRATEGY 2 DEVISE SESSION BASED
|
||||
#uri = "#{config.apiHost}/users/sign_in.json"
|
||||
#Ember.$.post uri, email: email, password: password, (result) =>
|
||||
# debugger
|
||||
#.fail (error) =>
|
||||
# # if error.status is 401
|
||||
# @set 'globals.flash_message', 'Invalid login'
|
||||
|
||||
# STRATEGY 2 DEVISE EMBER SIMPLE AUTH BASED
|
||||
@get('session').authenticate('authenticator:devise', email, password).catch (reason) =>
|
||||
message = if typeof(reason) is 'string' then reason else reason.error
|
||||
message ||= reason.message
|
||||
message ||= 'Invalid login'
|
||||
@set 'globals.flash_message', message
|
||||
false
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import BaseModal from 'ember-cli-dunlop/mixins/modal-base'
|
||||
|
||||
export default BaseModal.extend
|
||||
dunlop_base: true
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/number-input';
|
||||
@@ -0,0 +1,2 @@
|
||||
import Addon from 'ember-cli-dunlop/components/page-title'
|
||||
export default Addon
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/pagination-progress';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/push-action';
|
||||
@@ -0,0 +1,32 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
#filter_calls: 0
|
||||
tagName: 'tr'
|
||||
classNames: ['table-filters-row', 'ui', 'form']
|
||||
filters: Ember.Object.create()
|
||||
content: null # PagedRemoteArray from ember-cli-pagination
|
||||
key: 'name_eq'
|
||||
apply_filters: null # allow custom apply filters with application logic
|
||||
|
||||
init: ->
|
||||
@_super arguments...
|
||||
Ember.defineProperty @, 'filter_calls', Ember.computed.alias("filters.filter_calls")
|
||||
|
||||
actions:
|
||||
apply_filters: ->
|
||||
query = @get('filters')?.toProperties() || {}
|
||||
if @get('apply_filters')
|
||||
@get('apply_filters')(query)
|
||||
else # use standard implementation
|
||||
filter_calls = @incrementProperty('filter_calls')
|
||||
console.log "QUERY"
|
||||
console.log query
|
||||
@set 'content.page', 1
|
||||
@set 'content.lastPage', null
|
||||
@get('content').setOtherParam?('q', query)
|
||||
clear_filters: ->
|
||||
@set 'filters', Ember.Object.create()
|
||||
@send 'apply_filters'
|
||||
@set 'filter_calls', 0
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['actions']
|
||||
apply_filters: ->
|
||||
clear_filters: ->
|
||||
|
||||
actions:
|
||||
apply_filters: ->
|
||||
@get('apply_filters')(@)
|
||||
clear_filters: ->
|
||||
@get('clear_filters')(@)
|
||||
@@ -0,0 +1,90 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-date-range']
|
||||
classNameBindings: ['has_active_filter_value:active-filter']
|
||||
expandingTime: false
|
||||
weekSelector: false
|
||||
placeholder: '-/-'
|
||||
format: 'll'
|
||||
apply_filters: ->
|
||||
eager_filter: true # filter on enter
|
||||
week_selector_week: ''
|
||||
week_selector_year: String(new Date().getFullYear())
|
||||
has_active_filter_value: Ember.computed.or 'lower_bound', 'upper_bound'
|
||||
target_date_filter_text: Ember.computed '{lower_bound,upper_bound}', ->
|
||||
format = @get('format')
|
||||
if gteq = @get('lower_bound')
|
||||
gteq = gteq.format(format)
|
||||
else
|
||||
gteq = '-'
|
||||
if lteq = @get('upper_bound')
|
||||
lteq = lteq.format(format)
|
||||
else
|
||||
lteq = '-'
|
||||
"#{gteq} / #{lteq}"
|
||||
|
||||
|
||||
has_valid_week_selector_value: Ember.computed '{week_selector_week,week_selector_year}', ->
|
||||
return false unless week = @get('week_selector_week')
|
||||
week = parseInt(week)
|
||||
return false unless Number.isFinite(week)
|
||||
return false unless week < 54
|
||||
return false unless year = String(@get('week_selector_year'))
|
||||
return false unless year.length is 4
|
||||
true
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'lower_bound', Ember.computed.alias("filters.#{@get('key')}_gteq")
|
||||
Ember.defineProperty @, 'upper_bound', Ember.computed.alias("filters.#{@get('key')}_lteq")
|
||||
|
||||
actions:
|
||||
set_filter: (key, value) ->
|
||||
@set key, value
|
||||
@$('.dropdown').dropdown('hide') if key is 'upper_bound'
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
clear_filters: ->
|
||||
@set 'lower_bound', ''
|
||||
@set 'upper_bound', ''
|
||||
@$('.dropdown').dropdown('hide')
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
|
||||
set_filter_today: ->
|
||||
today = moment()
|
||||
@setProperties
|
||||
lower_bound: today
|
||||
upper_bound: today
|
||||
@get('apply_filters')(@)
|
||||
@$('.dropdown').dropdown('hide')
|
||||
|
||||
set_filter_this_week: ->
|
||||
today = moment()
|
||||
@setProperties
|
||||
lower_bound: today.clone().startOf('isoWeek')
|
||||
upper_bound: today.endOf('isoWeek')
|
||||
@get('apply_filters')(@)
|
||||
@$('.dropdown').dropdown('hide')
|
||||
|
||||
set_filter_this_month: ->
|
||||
today = moment()
|
||||
@setProperties
|
||||
lower_bound: today.clone().startOf('month')
|
||||
upper_bound: today.endOf('month')
|
||||
@get('apply_filters')(@)
|
||||
@$('.dropdown').dropdown('hide')
|
||||
|
||||
week_selector_activate: ->
|
||||
return unless week = @get('week_selector_week')
|
||||
week = parseInt(week)
|
||||
return unless Number.isFinite(week)
|
||||
return unless week < 54
|
||||
return unless year = String(@get('week_selector_year'))
|
||||
return unless year.match /^\d+$/
|
||||
week_start = moment(year).add(week, 'weeks').startOf('isoWeek')
|
||||
@setProperties
|
||||
lower_bound: week_start
|
||||
upper_bound: week_start.clone().endOf('isoWeek')
|
||||
@get('apply_filters')(@)
|
||||
@$('.dropdown').dropdown('hide')
|
||||
@@ -0,0 +1,15 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
placeholder: '-'
|
||||
eager_filter: true # filter on enter
|
||||
has_active_filter_value: Ember.computed.bool 'value'
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'value', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
select_date: (date) ->
|
||||
@set "filters.#{@get('key')}", date?.toISOString()
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@@ -0,0 +1,61 @@
|
||||
import Ember from 'ember'
|
||||
{get} = Ember
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-dropdown-select-multiple']
|
||||
classNameBindings: ['has_active_filter_value:active-filter', 'key']
|
||||
apply_filters: ->
|
||||
eager_filter: false # filter on single select
|
||||
has_active_filter_value: Ember.computed.bool 'selected.length'
|
||||
search_string: ''
|
||||
search_placeholder: 'Search...' #.htmlSafe()
|
||||
filtered_options: Ember.computed 'options.length', 'search_string', ->
|
||||
return @get('options') unless @get('search_string.length') > 1
|
||||
filtered_options = []
|
||||
tester = new RegExp(@get('search_string'), 'im')
|
||||
@get('options').forEach (option) =>
|
||||
value = if @get('labelPath') then get(option, @get('labelPath')) else option
|
||||
filtered_options.push option if tester.test value
|
||||
filtered_options
|
||||
|
||||
options: []
|
||||
labelPath: '' # if set, indicating an object select
|
||||
valuePath: 'id'
|
||||
selected: []
|
||||
selected_popup_content: Ember.computed 'selected.length', ->
|
||||
return '' unless @get('selected.length')
|
||||
if labelPath = @get('labelPath')
|
||||
result_html = ''
|
||||
@get('options').forEach (option) =>
|
||||
if get(option, @get('valuePath')) in @get('selected')
|
||||
result_html += '<br><hr>' if result_html
|
||||
result_html += get(option, labelPath)
|
||||
result_html
|
||||
else
|
||||
@get('selected').join('<br><hr>')
|
||||
selected_display: Ember.computed 'selected.length', ->
|
||||
if count = @get('selected.length')
|
||||
return '1 item' if count is 1
|
||||
"#{count} items"
|
||||
else
|
||||
'<i class="filter icon"></i>'.htmlSafe()
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'selected', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
apply_filters: ->
|
||||
@$('.dropdown').dropdown('hide')
|
||||
@get('apply_filters')(@)
|
||||
toggle_filter: (option, checked) ->
|
||||
value = if @get('labelPath') then get(option, @get('valuePath')) else option
|
||||
if checked
|
||||
@get('selected').pushObject value
|
||||
else
|
||||
@get('selected').removeObject value
|
||||
@apply_filters() if @get('eager_filter')
|
||||
clear_filter: ->
|
||||
@set 'selected', []
|
||||
@get('apply_filters')(@) # if @get('eager_filter') on clear always reload!
|
||||
@apply_filters()
|
||||
@@ -0,0 +1,43 @@
|
||||
import Ember from 'ember'
|
||||
{get} = Ember
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-input']
|
||||
classNameBindings: ['has_active_filter_value:active-filter', 'key']
|
||||
apply_filters: ->
|
||||
eager_filter: true # filter on enter
|
||||
has_active_filter_value: Ember.computed.bool 'selected'
|
||||
options: []
|
||||
labelPath: '' # if set, indicating an object select
|
||||
translationPath: '' # if set indicating a flat select requiring translated values
|
||||
valuePath: 'id'
|
||||
selected: null
|
||||
selected_display: Ember.computed 'selected', ->
|
||||
if selected = @get('selected')
|
||||
if labelPath = @get('labelPath')
|
||||
if obj = @get('options').findBy(@get('valuePath'), selected)
|
||||
get(obj, labelPath)
|
||||
else
|
||||
selected
|
||||
else if translationPath = @get('translationPath')
|
||||
t selected, scope: translationPath, default: selected
|
||||
else
|
||||
selected
|
||||
else
|
||||
'<i class="filter icon"></i>'.htmlSafe()
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'selected', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
set_filter: (value) ->
|
||||
if @get('labelPath')
|
||||
@set 'selected', get(value, @get('valuePath'))
|
||||
else
|
||||
@set 'selected', value
|
||||
@$('.dropdown').dropdown('hide')
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
clear_filter: ->
|
||||
@set 'selected', ''
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@@ -0,0 +1,40 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-input']
|
||||
classNameBindings: ['has_active_filter_value:active-filter']
|
||||
value: '' # defined on init
|
||||
apply_filters: ->
|
||||
eager_filter: true # filter on enter
|
||||
has_active_filter_value: Ember.computed.bool 'value'
|
||||
key: 'name_eq'
|
||||
placeholder: ''
|
||||
showSearchIcon: false # default false, too crowded ui if all fields have this icon
|
||||
|
||||
smart_placeholder: Ember.computed 'key', 'placeholder', ->
|
||||
return @get('placeholder') if @get('placeholder') # can be set from template
|
||||
return '' unless key = @get('key')
|
||||
switch
|
||||
when /_cont$/.test key then '~'
|
||||
when /_eq$/.test key then '=='
|
||||
when /_gt$/.test key then '>'
|
||||
when /_gteq$/.test key then '>='
|
||||
when /_lt$/.test key then '<'
|
||||
when /_lteq$/.test key then '<='
|
||||
when /_matches$/.test key then '%~%'
|
||||
when /_end$/.test key then '%--'
|
||||
when /_start/.test key then '--%'
|
||||
else ''
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'value', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
enterPressed: ->
|
||||
return unless @get('eager_filter')
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
clear_query: ->
|
||||
@set 'value', ''
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@@ -0,0 +1,41 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-number-range']
|
||||
classNameBindings: ['has_active_filter_value:active-filter']
|
||||
placeholder: '-/-'
|
||||
display_addition: '' # allow extra display value on cell. Year for example when number-range is weeks
|
||||
apply_filters: ->
|
||||
eager_filter: true # filter on enter
|
||||
has_active_filter_value: Ember.computed.or 'lower_bound', 'upper_bound'
|
||||
lower_bound_candidate: ''
|
||||
upper_bound_candidate: ''
|
||||
filter_text: Ember.computed '{lower_bound,upper_bound,display_addition}', ->
|
||||
gteq = @get('lower_bound') || '-'
|
||||
lteq = @get('upper_bound') || '-'
|
||||
range = "#{gteq} / #{lteq}"
|
||||
range += " #{@get('display_addition')}" if @get('display_addition')
|
||||
range
|
||||
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'lower_bound', Ember.computed.alias("filters.#{@get('key')}_gteq")
|
||||
Ember.defineProperty @, 'upper_bound', Ember.computed.alias("filters.#{@get('key')}_lteq")
|
||||
@set 'lower_bound_candidate', @get('lower_bound')
|
||||
@set 'upper_bound_candidate', @get('upper_bound')
|
||||
|
||||
actions:
|
||||
set_filter: (key, value) ->
|
||||
#@set key, value
|
||||
@set 'lower_bound', parseInt(@get('lower_bound_candidate')) || ''
|
||||
@set 'upper_bound', parseInt(@get('upper_bound_candidate')) || ''
|
||||
@$('.dropdown').dropdown('hide')
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
clear_filters: ->
|
||||
@set 'lower_bound', ''
|
||||
@set 'upper_bound', ''
|
||||
@set 'lower_bound_candidate', ''
|
||||
@set 'upper_bound_candidate', ''
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@@ -0,0 +1,23 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
classNames: ['filter', 'filter-input']
|
||||
classNameBindings: ['has_active_filter_value:active-filter', 'key']
|
||||
apply_filters: ->
|
||||
eager_filter: true # filter on enter
|
||||
has_active_filter_value: Ember.computed.bool 'selected'
|
||||
options: []
|
||||
selected: null
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty @, 'selected', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
set_filter: (value) ->
|
||||
@set 'selected', value
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
clear_filter: ->
|
||||
@set 'selected', ''
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@@ -0,0 +1,47 @@
|
||||
import Ember from 'ember'
|
||||
import BaseModal from 'ember-cli-dunlop/components/modals/base'
|
||||
export default BaseModal.extend
|
||||
current_selected: Ember.computed.alias 'modal_options.base.value'
|
||||
options: Ember.computed.alias 'modal_options.base.options'
|
||||
valueKey: Ember.computed.alias 'modal_options.base.valueKey'
|
||||
textKey: Ember.computed.alias 'modal_options.base.textKey'
|
||||
eager_filter: Ember.computed.alias 'modal_options.base.eager_filter'
|
||||
apply_filters: Ember.computed.alias 'modal_options.base.apply_filters'
|
||||
options_map: {}
|
||||
|
||||
willOpenModal: ->
|
||||
options_map = Ember.Object.create()
|
||||
valueKey = @get('valueKey')
|
||||
current_selected = @get('current_selected') || []
|
||||
@get('options').forEach (option) ->
|
||||
value_name = if valueKey then Ember.get(option, valueKey) else option
|
||||
options_map.set value_name, current_selected.includes(value_name)
|
||||
@set 'options_map', options_map
|
||||
|
||||
|
||||
actions:
|
||||
update_selection: ->
|
||||
valueKey = @get('valueKey')
|
||||
selected_options = @get('options').filter (option) =>
|
||||
value_name = if valueKey then Ember.get(option, valueKey) else option
|
||||
@get "options_map.#{value_name}"
|
||||
if valueKey
|
||||
selected_options = selected_options.mapBy valueKey
|
||||
@set 'current_selected', selected_options
|
||||
@get('apply_filters')(@) if @get('eager_filter')
|
||||
@send 'close'
|
||||
|
||||
toggle_selection: (option)->
|
||||
value_name = if @get('valueKey') then Ember.get(option, @get('valueKey')) else option
|
||||
@toggleProperty "options_map.#{value_name}"
|
||||
|
||||
select_all: ->
|
||||
Object.keys(@get('options_map')).forEach (value_name) =>
|
||||
@set "options_map.#{value_name}", true
|
||||
|
||||
select_none: ->
|
||||
Object.keys(@get('options_map')).forEach (value_name) =>
|
||||
@set "options_map.#{value_name}", false
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
tagName: 'th'
|
||||
textKey: 'name'
|
||||
classNames: ['filter', 'filter-select-multiple']
|
||||
classNameBindings: ['has_active_filter_values:active-filter']
|
||||
valueKey: null # assumed flat array
|
||||
value: []
|
||||
options: []
|
||||
key: 'name_in' # ransack key
|
||||
eager_filter: true # filter on enter
|
||||
apply_filters: ->
|
||||
has_active_filter_values: Ember.computed.bool 'value.length'
|
||||
|
||||
selectedTitle: Ember.computed 'value.length', ->
|
||||
return '--' unless @get('value.length')
|
||||
@get('value').join(",\n")
|
||||
|
||||
selectedDisplay: Ember.computed 'value.length', ->
|
||||
return '' unless @get('value.length')
|
||||
if @get('value.length') is 1
|
||||
value = @get("value.firstObject")
|
||||
if valueKey = @get('valueKey')
|
||||
option = @get('options').findBy(valueKey, value)
|
||||
Ember.get(option, @get('textKey'))
|
||||
else
|
||||
value
|
||||
else
|
||||
@get('value.length')
|
||||
|
||||
init: ->
|
||||
@_super(arguments...)
|
||||
Ember.defineProperty @, 'value', Ember.computed.alias("filters.#{@get('key')}")
|
||||
|
||||
actions:
|
||||
edit_selection: ->
|
||||
@modal 'table-filters/select-multiple-modal',
|
||||
title: "Select options"
|
||||
base: @
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/ui-calendar-moment';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/components/ui-markdown-popup';
|
||||
@@ -0,0 +1,20 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
classNameBindings: ['hasError:error', 'containerClass']
|
||||
classNames: ['field']
|
||||
disabled: false
|
||||
error_text: 'Please set...'
|
||||
|
||||
containerClass: Ember.computed 'attribute', ->
|
||||
return 'validated-attribute' unless record = @get('changeset._content')
|
||||
record_name = record.constructor.modelName || 'record'
|
||||
"validated-attribute-#{record_name}-#{Ember.String.dasherize(@get('attribute'))}".replace(/[\W_]/g, '-')
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty(@, "hasError", Ember.computed.bool("changeset.error.#{@get("attribute")}"))
|
||||
|
||||
actions:
|
||||
validateAttribute: (changeset, attribute) ->
|
||||
changeset.validate(attribute)
|
||||
@@ -0,0 +1,23 @@
|
||||
import Ember from 'ember'
|
||||
import { invokeAction } from 'ember-invoke-action'
|
||||
|
||||
export default Ember.Component.extend
|
||||
classNameBindings: ["hasError:error", "containerClass"]
|
||||
classNames: ['field']
|
||||
disabled: false
|
||||
|
||||
containerClass: Ember.computed "attribute", ->
|
||||
return "validated-input" unless record = @get('changeset._content')
|
||||
record_name = record.constructor.modelName || 'record'
|
||||
"validated-input-#{record_name}-#{Ember.String.dasherize(@get("attribute"))}".replace(/[\W_]/g, '-')
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
Ember.defineProperty(@, "hasError", Ember.computed.bool("changeset.error.#{@get("attribute")}"))
|
||||
|
||||
actions:
|
||||
validateProperty: (changeset, property) ->
|
||||
changeset.validate(property)
|
||||
inputEnter: (value)->
|
||||
#https://github.com/DockYard/ember-one-way-controls/blob/master/addon/components/one-way-input.js
|
||||
invokeAction(@, enter, value) if enter = @get('enter')
|
||||
@@ -0,0 +1,37 @@
|
||||
import Ember from 'ember'
|
||||
|
||||
export default Ember.Component.extend
|
||||
classNameBindings: ['hasError:error', 'containerClass']
|
||||
classNames: ['field']
|
||||
includeBlank: false
|
||||
disabled: false
|
||||
valueKey: null # assumed flat array
|
||||
textKey: 'name'
|
||||
|
||||
containerClass: Ember.computed 'attribute', ->
|
||||
return 'validated-select' unless record = @get('changeset._content')
|
||||
record_name = record.constructor.modelName || 'record'
|
||||
"validated-select-#{record_name}-#{Ember.String.dasherize(@get('attribute'))}".replace(/[\W_]/g, '-')
|
||||
|
||||
set_value_to_first_option_on_non_blank_list: Ember.observer 'options.length', ->
|
||||
return unless @get('options.length')
|
||||
attribute = @get('attribute')
|
||||
if not @get('includeBlank') and not @get("changeset.#{attribute}")
|
||||
value = if @get('valueKey') then @get("options.firstObject.#{@get('valueKey')}") else @get('options.firstObject')
|
||||
@set "changeset.#{attribute}", value
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
console.log('No attribute given for validated-select') unless attribute = @get('attribute')
|
||||
Ember.defineProperty(@, 'hasError', Ember.computed.bool("changeset.error.#{attribute}"))
|
||||
|
||||
blankContent: Ember.computed 'includeBlank', ->
|
||||
setting = @get('includeBlank')
|
||||
return setting if typeof setting is 'string'
|
||||
'--'
|
||||
|
||||
actions:
|
||||
hasChanged: (value) ->
|
||||
[changeset, property] = [@get('changeset'), @get('attribute')]
|
||||
changeset.set property, value
|
||||
changeset.validate(property)
|
||||
@@ -0,0 +1 @@
|
||||
export { default, anyPermissionStartsWith } from 'ember-cli-dunlop/helpers/any-permission-starts-with';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, dunlopCan } from 'ember-cli-dunlop/helpers/dunlop-can';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, formatDate } from 'ember-cli-dunlop/helpers/format-date';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, hasPermissionOfType } from 'ember-cli-dunlop/helpers/has-permission-of-type';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, minuteOfDay } from 'ember-cli-dunlop/helpers/minute-of-day';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, numberToXlsHeader } from 'ember-cli-dunlop/helpers/number-to-xls-header';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, t } from 'ember-cli-dunlop/helpers/t';
|
||||
@@ -0,0 +1 @@
|
||||
export { default, initialize } from 'ember-cli-dunlop/initializers/ember-cli-dunlop-overrides';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/serializers/create-and-update';
|
||||
@@ -0,0 +1,3 @@
|
||||
unless isFirst
|
||||
i.right.angle.icon.divider
|
||||
= yield
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="ui breadcrumb">
|
||||
{{yield (hash item=(component "d-breadcrumb" parent=this register=(action 'registerItem') unregister=(action 'unregisterItem')))}}
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
= message
|
||||
@@ -0,0 +1,9 @@
|
||||
.field
|
||||
.ui.left.icon.input
|
||||
i.user.icon
|
||||
= input type='email' value=identification enter='submitLogin' placeholder="e-mail" class='login-email'
|
||||
.field
|
||||
.ui.left.icon.input
|
||||
i.lock.icon
|
||||
= input type='password' value=password enter='submitLogin' placeholder='password' class='login-password'
|
||||
.ui.fluid.large.orange.submit.button{action 'submitLogin'} Login
|
||||
@@ -0,0 +1,5 @@
|
||||
if back
|
||||
= link-to back class='title-back-link'
|
||||
i.left.arrow.icon
|
||||
= title
|
||||
= yield
|
||||
@@ -0,0 +1,11 @@
|
||||
{{yield (hash
|
||||
input=(component "table-filters/input" apply_filters=(action 'apply_filters') filters=filters)
|
||||
date=(component "table-filters/date" apply_filters=(action 'apply_filters') filters=filters)
|
||||
date-range=(component "table-filters/date-range" apply_filters=(action 'apply_filters') filters=filters)
|
||||
number-range=(component "table-filters/number-range" apply_filters=(action 'apply_filters') filters=filters)
|
||||
dropdown-select=(component "table-filters/dropdown-select" apply_filters=(action 'apply_filters') filters=filters)
|
||||
dropdown-select-multiple=(component "table-filters/dropdown-select-multiple" apply_filters=(action 'apply_filters') filters=filters)
|
||||
option-buttons=(component "table-filters/option-buttons" apply_filters=(action 'apply_filters') filters=filters)
|
||||
select-multiple=(component "table-filters/select-multiple" apply_filters=(action 'apply_filters') filters=filters)
|
||||
actions=(component 'table-filters/actions' apply_filters=(action 'apply_filters') clear_filters=(action 'clear_filters') filter_calls=filter_calls)
|
||||
)}}
|
||||
@@ -0,0 +1,39 @@
|
||||
each options as |option|
|
||||
.ui.grid{action 'toggle_selection' option}
|
||||
.four.wide-column
|
||||
if valueKey
|
||||
with (get option valueKey) as |option_value|
|
||||
if (get options_map option_value)
|
||||
/a.fa.fa-2x.fa-check-square-o
|
||||
button.ui.basic.icon.button: i.checkmark.box.icon
|
||||
else
|
||||
button.ui.basic.icon.button: i.square.outline.icon
|
||||
/a.fa.fa-2x.fa-square-o
|
||||
/= input type='checkbox' checked=(get options_map option_value)
|
||||
else
|
||||
if (get options_map option)
|
||||
/a.fa.fa-2x.fa-check-square-o
|
||||
button.ui.basic.icon.button: i.checkmark.box.icon
|
||||
else
|
||||
/a.fa.fa-2x.fa-square-o
|
||||
button.ui.basic.icon.button: i.square.outline.icon
|
||||
/= input type='checkbox' checked=(get options_map option)
|
||||
.twelve.wide.column
|
||||
if valueKey
|
||||
= get option textKey
|
||||
else
|
||||
= option
|
||||
//UNCOMMENT THE SECTION BELOW FOR DEBUGGING
|
||||
/each-in options_map as |value is_selected|
|
||||
.row
|
||||
.small-2.columns: if is_selected 'Ja' 'Nee'
|
||||
.small-10.columns= value
|
||||
.modal-actions.sticky
|
||||
button.ui.primary.button.modal-save.right{action 'update_selection'}= t 'general.update'
|
||||
button.ui.button.modal-rollback{action 'close'}= t 'general.rollback'
|
||||
span
|
||||
/span.fa.fa-lg.fa-check-square-o{action 'select_all'}
|
||||
button.ui.basic.icon.button{action 'select_all'}: i.checkmark.box.icon
|
||||
span
|
||||
/span.fa.fa-lg.fa-square-o{action 'select_none'}
|
||||
button.ui.basic.icon.button{action 'select_none'}: i.square.outline.icon
|
||||
@@ -0,0 +1,5 @@
|
||||
button.ui.tiny.primary.basic.icon.button{ action 'apply_filters'}: i.filter.icon
|
||||
if filter_calls
|
||||
|
|
||||
button.ui.tiny.secondary.basic.icon.button{ action 'clear_filters'}: i.remove.icon
|
||||
= yield
|
||||
@@ -0,0 +1,27 @@
|
||||
ui-dropdown class='basic pointing' action='nothing'
|
||||
= target_date_filter_text
|
||||
.menu
|
||||
.item= ui-calendar-moment type='date' momentValue=lower_bound onChange=(action 'set_filter' 'lower_bound') allowClear=true
|
||||
.divider
|
||||
.item= ui-calendar-moment type='date' momentValue=upper_bound onChange=(action 'set_filter' 'upper_bound') allowClear=true
|
||||
if expandingTime
|
||||
.divider
|
||||
.item
|
||||
button.ui.mini.primary.button{action 'set_filter_today'}= t 'date.today'
|
||||
'
|
||||
button.ui.mini.primary.button{action 'set_filter_this_week'}= t 'date.this_week'
|
||||
'
|
||||
button.ui.mini.primary.button{action 'set_filter_this_month'}= t 'date.this_month'
|
||||
if weekSelector
|
||||
.ui.horizontal.divider= t 'date.unit.week'
|
||||
.divider
|
||||
.item
|
||||
.ui.input.select-week= input type='number' value=week_selector_week placeholder='week' size=3 enter='week_selector_activate'
|
||||
' /
|
||||
.ui.input.select-year= input type='number' value=week_selector_year placeholder='year' size=5 enter='week_selector_activate'
|
||||
if has_valid_week_selector_value
|
||||
'
|
||||
button.ui.mini.secondary.icon.button{action 'week_selector_activate'}: i.filter.icon
|
||||
= yield
|
||||
if has_active_filter_value
|
||||
i.close.icon.clear-target-date-filter{action 'clear_filters'}
|
||||
@@ -0,0 +1,2 @@
|
||||
= pick-a-date date=(readonly (get filters key)) on-selected=(action 'select_date') placeholder=placeholder
|
||||
= yield
|
||||
@@ -0,0 +1,22 @@
|
||||
ui-dropdown class='right basic labeled icon' action='nothing'
|
||||
if selected.length
|
||||
= ui-popup html=selected_popup_content position='bottom center'
|
||||
span= selected_display
|
||||
else
|
||||
i.filter.icon
|
||||
i.dropdown.icon
|
||||
.menu
|
||||
.ui.icon.action.input
|
||||
i.search.icon
|
||||
= input value=search_string placeholder=search_placeholder
|
||||
button.ui.secondary.icon.button{action 'apply_filters'}
|
||||
i.filter.icon
|
||||
.scrolling.menu
|
||||
each filtered_options as |option|
|
||||
if labelPath
|
||||
ui-checkbox class='item' checked=(contains (get option valuePath) selected) label=(get option labelPath) onChange=(action 'toggle_filter' option)
|
||||
else
|
||||
ui-checkbox class='item' checked=(contains option selected) label=option onChange=(action 'toggle_filter' option)
|
||||
if selected.length
|
||||
i.pointable.remove.icon{action 'clear_filter'}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
ui-dropdown class='right basic labeled icon' action='nothing'
|
||||
= selected_display
|
||||
i.dropdown.icon
|
||||
.menu
|
||||
each options as |option|
|
||||
.item{action 'set_filter' option}
|
||||
if labelPath
|
||||
= get option labelPath
|
||||
else
|
||||
if translationPath
|
||||
= t option scope=translationPath
|
||||
else
|
||||
= option
|
||||
if has_active_filter_value
|
||||
i.pointable.close.icon{action 'clear_filter'}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
.ui.fluid.icon.input
|
||||
= input value=value enter='enterPressed' placeholder=smart_placeholder
|
||||
if has_active_filter_value
|
||||
i.close.action.icon{action 'clear_query'}
|
||||
else if showSearchIcon
|
||||
i.search.icon
|
||||
= yield
|
||||
@@ -0,0 +1,10 @@
|
||||
ui-dropdown class='right basic labeled top right pointing icon' action='nothing'
|
||||
= filter_text
|
||||
.menu
|
||||
.item= input type='number' value=lower_bound_candidate enter=(action 'set_filter')
|
||||
.divider
|
||||
.item= input type='number' value=upper_bound_candidate enter=(action 'set_filter')
|
||||
= yield
|
||||
if has_active_filter_value
|
||||
i.close.icon.clear-target-date-filter{action 'clear_filters'}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
.ui.mini.buttons
|
||||
each options as |option|
|
||||
button.ui.button click="action 'set_filter' option" class="{{if (eq selected option) 'active-button'}}"
|
||||
= option
|
||||
if has_active_filter_value
|
||||
i.close.icon{action 'clear_filter'}
|
||||
@@ -0,0 +1,4 @@
|
||||
button.ui.tiny.icon.button{action 'edit_selection'} title=selectedTitle
|
||||
i.list.icon
|
||||
== selectedDisplay
|
||||
= yield
|
||||
@@ -0,0 +1,3 @@
|
||||
= yield
|
||||
if hasError
|
||||
.ui.pointing.red.basic.label= error_text
|
||||
@@ -0,0 +1,12 @@
|
||||
/ based on https://www.emberscreencasts.com/posts/172-displaying-errors-inline-with-ember-changeset-validations
|
||||
if label
|
||||
label= label
|
||||
else
|
||||
if labelPath
|
||||
label= t labelPath
|
||||
|
||||
one-way-input value=(get changeset attribute) update=(action (mut (get changeset attribute))) onblur=(action 'validateProperty' changeset attribute) disabled=disabled onenter='inputEnter'
|
||||
|
||||
if (get changeset.error attribute)
|
||||
each (get (get changeset.error attribute) 'validation') as |error|
|
||||
.ui.pointing.red.basic.label= error
|
||||
@@ -0,0 +1,22 @@
|
||||
/ based on validated-input
|
||||
if label
|
||||
label= label
|
||||
else
|
||||
if labelPath
|
||||
label= t labelPath
|
||||
else
|
||||
label= attribute
|
||||
|
||||
x-select value=(get changeset attribute) on-change=(action "hasChanged") disabled=disabled as |xs|
|
||||
if includeBlank
|
||||
option= blankContent
|
||||
each options as |option|
|
||||
if valueKey
|
||||
xs.option value=(get option valueKey)
|
||||
= get option textKey
|
||||
else
|
||||
xs.option value=option
|
||||
= option
|
||||
if (get changeset.error attribute)
|
||||
each (get (get changeset.error attribute) 'validation') as |error|
|
||||
.ui.pointing.red.basic.label= error
|
||||
@@ -0,0 +1,23 @@
|
||||
if show_error
|
||||
.dunlop-global-error.ui.negative.message
|
||||
if show_as_list
|
||||
ul
|
||||
each error.errors as |single_error|
|
||||
li
|
||||
= single_error.status
|
||||
span -
|
||||
= single_error.title
|
||||
else
|
||||
.ui.grid
|
||||
.row
|
||||
.four.wide.column= single_error.status
|
||||
.twelve.wide.column= single_error.title
|
||||
.row
|
||||
/collapsible-content collapsed=true
|
||||
/ == single_error.detail
|
||||
== single_error.detail
|
||||
.row
|
||||
button.ui.small.basic.button.pull-right{action 'reload_page'} Reload page!
|
||||
button.ui.small.primary.button{ action 'clear_error_and_go_home'} Go to homepage
|
||||
span
|
||||
button.ui.small.button{ action 'clear_error'} Close
|
||||
@@ -0,0 +1,4 @@
|
||||
p= body
|
||||
.modal-actions.sticky
|
||||
button.ui.basic.button.modal-close{action "close"}= t 'confirm.cancel'
|
||||
button.ui.primary.button.modal-confirm.pull-right{action "confirm"}= t 'confirm.confirm'
|
||||
@@ -0,0 +1,8 @@
|
||||
sortable-group tagName="ul" onChange="reorderItems" class="sortable-list" as |group|
|
||||
each sorted_records as |record|
|
||||
sortable-item tagName="li" model=record group=group handle=".handle"
|
||||
/span.handle
|
||||
i.sort.icon.handle
|
||||
= record.name
|
||||
.modal-actions.sticky
|
||||
button.ui.basic.button.modal-close.pull-right{ action "close"}= t 'general.close'
|
||||
@@ -0,0 +1,11 @@
|
||||
.overlay{action "closeOnOverlay"}
|
||||
.modal{action "modalClick" bubbles=false preventDefault=false}
|
||||
.modal-header
|
||||
h3.flush--top= title
|
||||
.ui.divider
|
||||
.modal-body.ui.form
|
||||
if alert_message
|
||||
.ui.negative.message.modal-alert
|
||||
i.close.icon{action (mut alert_message) ''}
|
||||
== alert_message
|
||||
= partial partialName
|
||||
@@ -0,0 +1 @@
|
||||
/ to fix a disconnected outlet issue https://github.com/emberjs/ember-inspector/issues/625
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/transforms/datemoment';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/transforms/moment';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/utils/date-sort';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'ember-cli-dunlop/utils/integer-to-string';
|
||||
Reference in New Issue
Block a user