-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a component for creating or updating models
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
`import Ember from 'ember'` | ||
|
||
ModelFormComponent = Ember.Component.extend | ||
typeKey: undefined | ||
typeHumanName: undefined | ||
model: undefined | ||
|
||
removeConfirmationName: (-> | ||
"remove#{@typeKey.capitalize()}Confirmation" | ||
).property('typeKey') | ||
removeConfirmationTitle: '确认删除' | ||
removeConfirmationMessage: (-> | ||
"您确认需要删除该#{@typeHumanName}吗?" | ||
).property('typeHumanName') | ||
removeConfirmationButtons: [ | ||
Ember.Object.create title: '确认', clicked: "confirmRemove" | ||
Ember.Object.create title: '取消', dismiss: 'modal' | ||
] | ||
|
||
save: 'save' | ||
cancel: 'cancel' | ||
remove: 'remove' | ||
confirmRemove: 'confirmRemove' | ||
revertChanges: 'revertChanges' | ||
return: 'return' | ||
|
||
actions: | ||
save: -> @sendAction('save') | ||
cancel: -> @sendAction('cancel') | ||
remove: -> @sendAction('remove') | ||
confirmRemove: -> @sendAction('confirmRemove') | ||
revertChanges: -> @sendAction('revertChanges') | ||
return: -> @sendAction('return') | ||
|
||
`export default ModelFormComponent` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
em-form model=model form_layout="horizontal" submit_button=false | ||
h2 | ||
= formLegend | ||
|
||
yield | ||
|
||
.form-group.buttons | ||
.col-sm-2 | ||
.col-sm-10 | ||
button.btn.btn-primary{action 'save'} | ||
i.fa.fa-save | ||
| 保存 | ||
if model.isNew | ||
button.btn.btn-link{action 'cancel'} | ||
| 取消 | ||
else | ||
button.btn.btn-danger{action 'remove'} | ||
i.fa.fa-times 删除 | ||
button.btn.btn-link{action 'revertChanges'} | ||
| 重置 | ||
button.btn.btn-default{action 'return'} | ||
i.fa.fa-mail-reply | ||
| 返回 | ||
|
||
bs-modal name=removeConfirmationName fade=true footerButtons=removeConfirmationButtons title=removeConfirmationTitle | ||
p= removeConfirmationMessage |