Skip to content

Commit

Permalink
Use Ember EasyDecorator
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriaLeshchenko committed May 30, 2014
1 parent c06e663 commit ed2f49a
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 320 deletions.
5 changes: 3 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module.exports = function(grunt) {
'src/application/routes/**/*.coffee',
'src/application/controllers/**/*.coffee',
'src/application/form_config.coffee',
'src/application/adapters/*.coffee'
'src/application/adapters/*.coffee',
'src/application/decorators/*.coffee'
]
}
}
Expand All @@ -52,7 +53,7 @@ module.exports = function(grunt) {
options: { mangle: false, compress: false },

dist: {
src: ['src/ember-easyForm.js', 'vendor/jquery.cookie/jquery.cookie.js', 'dist/ember-admin.js', 'dist/templates.js'],
src: ['src/ember-easyForm.js', 'src/ember-easy-decorator.js', 'vendor/jquery.cookie/jquery.cookie.js', 'dist/ember-admin.js', 'dist/templates.js'],
dest: 'dist/ember-admin.min.js'
}
},
Expand Down
250 changes: 74 additions & 176 deletions dist/ember-admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/ember-admin.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,9 @@ function program1(depth0,data) {
function program2(depth0,data) {

var helper, options;
data.buffer.push(escapeExpression((helper = helpers['bound-input'] || (depth0 && depth0['bound-input']),options={hash:{
data.buffer.push(escapeExpression((helper = helpers['decorator-input'] || (depth0 && depth0['decorator-input']),options={hash:{
'inputConfig': ("class:form-control")
},hashTypes:{'inputConfig': "STRING"},hashContexts:{'inputConfig': depth0},contexts:[depth0],types:["ID"],data:data},helper ? helper.call(depth0, "attribute.name", options) : helperMissing.call(depth0, "bound-input", "attribute.name", options))));
},hashTypes:{'inputConfig': "STRING"},hashContexts:{'inputConfig': depth0},contexts:[depth0],types:["ID"],data:data},helper ? helper.call(depth0, "attribute.name", options) : helperMissing.call(depth0, "decorator-input", "attribute.name", options))));
}

function program4(depth0,data) {
Expand All @@ -743,7 +743,7 @@ function program6(depth0,data) {

stack1 = (helper = helpers['form-for'] || (depth0 && depth0['form-for']),options={hash:{
'wrapper': ("twitter-bootstrap")
},hashTypes:{'wrapper': "STRING"},hashContexts:{'wrapper': depth0},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),contexts:[depth0],types:["ID"],data:data},helper ? helper.call(depth0, "controller.model", options) : helperMissing.call(depth0, "form-for", "controller.model", options));
},hashTypes:{'wrapper': "STRING"},hashContexts:{'wrapper': depth0},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),contexts:[depth0],types:["ID"],data:data},helper ? helper.call(depth0, "controller.decorator.model", options) : helperMissing.call(depth0, "form-for", "controller.decorator.model", options));
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
else { data.buffer.push(''); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ Admin.Base.Controllers.AdminBaseController = Ember.ObjectController.extend Admin
Admin.Mixins.Controllers.AttributesMixin,
Admin.Mixins.Controllers.PaginationMixin,
Admin.Mixins.Controllers.BatchActionsMixin,
Admin.Mixins.Controllers.FormActionsMixin
Admin.Mixins.Controllers.FormActionsMixin,

decorator: (->
Admin.BaseDecorator.create(model: @get('model')) if @get('model')
).property('model')
24 changes: 24 additions & 0 deletions src/application/decorators/base_decorator.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Admin.BaseDecorator = EmberEasyDecorator.extend

unknownProperty: (propertyName) ->
if /Value$/.test(propertyName)
modelProperty = propertyName.substr(0, propertyName.length - 5)
return @get('model.%@'.fmt(modelProperty))
if /SectionFields$/.test(propertyName)
return @_createSectionComputed(propertyName)
if @get('model.%@'.fmt(propertyName))
if @_checkMapProperty(propertyName) || @_checkFileupload(propertyName)
return {options: {isVisible: false}}
if Admin.DSL.Attributes.isBelongsTo(@get("model").constructor, propertyName)
@set('%@Collection'.fmt(propertyName), @get('model.store').findAll(propertyName))
return {html: {optionLabelPath: 'content.title'}, type: 'select', options: {relation: true}}
else
return @get('model.%@'.fmt(propertyName))

_checkMapProperty: (property) ->
exist = @get("model.asGoogleMap") isnt `undefined` and @get("model.asGoogleMap").indexOf(property) >= 0
return exist if exist
@get("model.asYandexMap") isnt `undefined` and @get("model.asYandexMap").indexOf(property) >= 0

_checkFileupload: (property) ->
@get("model.fileuploads") isnt `undefined` and @get("model.fileuploads").indexOf(property) >= 0
Loading

0 comments on commit ed2f49a

Please sign in to comment.