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
@@ -0,0 +1,28 @@
import Ember from 'ember'
import layout from '../templates/components/collapsible-content'
Component = Ember.Component.extend
layout: layout
collapsed: true
classNames: ['collapsible-content-container']
title: Ember.computed 'titleSpec', ->
title = "#{@get('titleSpec')}"
options = {}
# allow modelPath as argument, useful for page-title 'action.new_model' modelPath='models.projects.site' etc
if modelPath = @get('modelPath')
options.model = t(modelPath)
# interpret the given argument as a translation string if it matches the characteristics
title = tspan(title, options) if is_translation_path(title)
title.htmlSafe()
actions:
toggleCollapsed: -> @toggleProperty('collapsed')
Component.reopenClass
positionalParams: ['titleSpec']
export default Component
@@ -0,0 +1,33 @@
import Ember from 'ember'
import layout from '../templates/components/editable-attribute'
export default Ember.Component.extend
layout: layout
attributeName: 'name'
can_make_editable: true
isEditing: false
validation_message: ''
make_editable: (-> @set 'isEditing', true ).on 'doubleClick'
init: ->
@_super arguments...
@set 'isEditing', true if @get('model.isNew')
actions:
destroyRecord: ->
@set 'validation_message', ''
model = @get('model')
model.rollbackAttributes()
model.destroyRecord()
editRecord: -> @set('isEditing', true)
saveRecord: ->
model = @get('model')
@set 'validation_message', ''
if validate = @get('validate')
@set 'validation_message', 'Must be given' if validate is 'presence' and not @get('model.name')
unless @get 'validation_message'
@set 'isEditing', false
model.save()
rollbackRecord: ->
@set 'validation_message', ''
model = @get('model')
model.rollbackAttributes()
@set 'isEditing', false
+28
View File
@@ -0,0 +1,28 @@
import Ember from 'ember'
#import layout from '../templates/components/error-handling'
export default Ember.Component.extend
#classNames: ['dunlop-global-error', 'ui', 'negative', 'message']
#classNameBindings: ['show_error:active:hidden']
#layout: layout
error: {}
show_error: true
show_as_list: Ember.computed.gt 'error.errors.length', 1
error_header: Ember.computed 'error.message', ->
@get('error.message') || 'Oops'
error_body: Ember.computed 'show_as_list', ->
''
single_error: Ember.computed 'error.message', ->
Ember.Object.create
title: @get('error.message')
status: @get('error.status')
detail: @get('error.backtrace')
actions:
reload_page: -> window.location.reload()
clear_error: -> @set 'show_error', false
clear_error_and_go_home: ->
@set 'show_error', false
Ember.getOwner(this).lookup('route:application').transitionTo('index')
+18
View File
@@ -0,0 +1,18 @@
import Ember from 'ember'
# = number-input numericValue=path.to.numeric_value, taken from mozo
export default Ember.TextField.extend
type: 'number'
attributeBindings: ['min', 'max', 'step']
classNames: ['number-input']
focusIn: -> @$().select()
init: ->
@_super arguments...
value = @get 'numericValue'
# value? returns true on 0
@set 'value', if value? then String(value) else ''
handle_value_change: Ember.observer 'value', ->
string_value = @get('value')
setValue = parseFloat(string_value)
@set "numericValue", if Number.isFinite(setValue) then setValue else null
+24
View File
@@ -0,0 +1,24 @@
import Ember from 'ember'
Component = Ember.Component.extend
tagName: 'h2'
classNames: ['page-title', 'ui', 'header']
back: null
title: Ember.computed 'titleSpec', ->
title = "#{@get('titleSpec')}"
options = {}
# allow modelPath as argument, useful for page-title 'action.new_model' modelPath='models.projects.site' etc
if modelPath = @get('modelPath')
options.model = t(modelPath)
# interpret the given argument as a translation string if it matches the characteristics
title = tspan(title, options) if is_translation_path(title)
title.htmlSafe()
Component.reopenClass
positionalParams: ['titleSpec']
export default Component
@@ -0,0 +1,16 @@
import Ember from 'ember'
import layout from '../templates/components/pagination-progress'
export default Ember.Component.extend
tagName: 'span'
layout: layout
progressText: Ember.computed 'content.page', 'content.content.length', 'content.perPage', 'content.total_count', ->
per_page = @get('content.perPage') || 10
current_page = @get('content.page') || 1
records_displayed = @get('content.content.length') || 0
total_count = @get('content.meta.total_count') || 0
from_item = (current_page - 1) * per_page + 1
to_item = Math.min(from_item + records_displayed - 1, total_count)
from_item = 0 unless total_count
"#{from_item} - #{to_item} / #{total_count}"
+39
View File
@@ -0,0 +1,39 @@
import Ember from 'ember'
import layout from '../templates/components/push-action'
export default Ember.Component.extend
layout: layout
tagName: 'button'
type: ''
size: ''
model: null
classNames: ['push-action', 'ui', 'icon', 'button']
classNameBindings: ['type', 'size', 'colorClass']
click: ->
@sendAction 'action', @get('model')
colorClass: Ember.computed 'type', ->
return unless type = @get('type')
switch type
when 'save' then 'primary'
when 'destroy' then 'negative'
when 'new' then 'grey'
else ''
iconClass: Ember.computed 'type', ->
return unless type = @get('type')
switch type
when 'edit' then 'pencil'
when 'new' then 'plus'
when 'show' then 'eye'
when 'sort' then 'sort'
when 'rollback' then 'undo'
when 'save' then 'save'
when 'destroy' then 'trash'
when 'authorization' then 'users' # 'unlock alternate'
when 'constraints' then 'connectdevelop'
when 'position' then 'random'
when 'contract' then 'file text'
when 'raster' then 'grid layout'
else type
@@ -0,0 +1,24 @@
import Ember from 'ember'
import UiCalendarComponent from 'ember-semantic-ui-calendar/components/ui-calendar'
{ computed, inject, merge } = Ember
export default UiCalendarComponent.extend
momentValue: null
firstDayOfWeek: null
is_date: false
# Provide the Date object that is used by ui-calendar
date: computed('momentValue', ->
if momentValue = @get('momentValue') then momentValue.toDate() else null
).readOnly()
willInitSemantic: (settings) ->
settings.firstDayOfWeek = if Number.isFinite(@get('firstDayOfWeek')) then @get('firstDayOfWeek') else (if Number.isFinite(@get('globals.first_day_of_week')) then @get('globals.first_day_of_week') else 1)
@_super arguments...
@set('is_date', true) if @get('momentValue._f') is 'YYYY-MM-DD' or @get('momentValue._ambigTime') or @get('type') is 'date'
merge settings,
onChange: (date) ->
# Wraps the Date in a moment object an triggers the onChange action
momentDate = if date then moment(date) else null
momentDate._ambigTime = true if momentDate and @get('is_date')
@sendAction 'onChange', momentDate
+14
View File
@@ -0,0 +1,14 @@
import Ember from 'ember'
import layout from '../templates/components/ui-markdown-popup'
import UiPopup from 'semantic-ui-ember/components/ui-popup'
import showdown from 'showdown'
export default UiPopup.extend
extensions: []
init: ->
markdown = @get('markdown')
converter = new showdown.Converter(@get('extensions'))
html = converter.makeHtml(markdown)
@attrs.html = html
@_super arguments...
layout: layout