initial github commit

This commit is contained in:
2017-12-21 11:42:41 +01:00
commit a57548c7da
209 changed files with 3841 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/collapsible-content';
+15
View File
@@ -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...
+20
View File
@@ -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)
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/editable-attribute';
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/error-handling'
+11
View File
@@ -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)
+43
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
import BaseModal from 'ember-cli-dunlop/mixins/modal-base'
export default BaseModal.extend
dunlop_base: true
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/number-input';
+2
View File
@@ -0,0 +1,2 @@
import Addon from 'ember-cli-dunlop/components/page-title'
export default Addon
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/pagination-progress';
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/push-action';
+32
View File
@@ -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')
+15
View File
@@ -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')
+40
View File
@@ -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: @
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/ui-calendar-moment';
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-cli-dunlop/components/ui-markdown-popup';
+20
View File
@@ -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)
+23
View File
@@ -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')
+37
View File
@@ -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)