-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b19cde7
commit 7c47a0d
Showing
8 changed files
with
121 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
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
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,5 @@ | ||
#prepaids-admin-view | ||
.prepaid | ||
border: 1px solid black | ||
border-radius: 3px | ||
padding: 15px |
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
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,29 @@ | ||
// DNT | ||
flat-layout | ||
.container | ||
form(action="") | ||
label | ||
| Prepaid ID: | ||
input(v-model="searchInput") | ||
button(@click.prevent="searchForPrepaid") | ||
| Search | ||
.prepaid(v-for="prepaid in prepaids") | ||
ul | ||
li | ||
| id: {{ prepaid._id }} | ||
li | ||
| creator: {{ prepaid.creator }} | ||
li | ||
="startDate: " | ||
input(v-model="prepaid.startDate") | ||
=" " | ||
| {{ formatDate(prepaid.startDate) }} | ||
li | ||
="endDate: " | ||
input(v-model="prepaid.endDate") | ||
=" " | ||
| {{ formatDate(prepaid.endDate) }} | ||
li | ||
button(@click.prevent="savePrepaid(prepaid)") | ||
| Save prepaid | ||
{{ savedStatus[prepaid._id] }} |
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,43 @@ | ||
template = require 'templates/base-flat' | ||
require('vendor/co') | ||
api = require 'core/api' | ||
FlatLayout = require 'core/components/FlatLayout' | ||
store = require('core/store') | ||
|
||
PrepaidsAdminView = Vue.extend | ||
name: 'prepaids-admin-view' | ||
template: require('templates/admin/prepaids-admin-view')() | ||
components: | ||
'flat-layout': FlatLayout | ||
props: {} | ||
created: -> | ||
data: -> | ||
searchInput: '59162c58e5816532e0e69634' | ||
prepaids: [] | ||
savedStatus: {} | ||
computed: | ||
{} | ||
methods: | ||
formatDate: (date) -> | ||
moment(date).format('dddd, MMM Do, YYYY, h:mma ZZ') | ||
searchForPrepaid: co.wrap -> | ||
prepaid = yield api.prepaids.get({ prepaidID: @searchInput }) | ||
@prepaids = [prepaid] | ||
@savedStatus[prepaid._id] = null | ||
savePrepaid: co.wrap (prepaid) -> | ||
console.log "Saving prepaid:", prepaid.endDate | ||
index = _.findIndex(@prepaids, {_id: prepaid._id}) | ||
try | ||
result = yield api.prepaids.put({ prepaid }) | ||
console.log result | ||
console.log "Result from PUT:", result.endDate | ||
savedPrepaid = yield api.prepaids.get({ prepaidID: prepaid._id }) | ||
console.log "Result from GET:", savedPrepaid.endDate | ||
Vue.set(@prepaids, index, savedPrepaid) | ||
Vue.set(@savedStatus, prepaid._id, 'saved') | ||
catch e | ||
console.log e | ||
@savedStatus[prepaid._id] = 'error' | ||
|
||
VueWrapper = require('views/core/VueWrapper') | ||
module.exports = VueWrapper.RootComponent(PrepaidsAdminView) |
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
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