Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix onAfterAction hook for adminCreateRouteViewOptions #340

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/both/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ adminCreateRouteViewOptions = (collection, collectionName) ->
Session.set 'admin_title', collectionName
Session.set 'admin_subtitle', 'View'
Session.set 'admin_collection_name', collectionName
collection.routes?.view?.onAfterAction
collection.routes?.view?.onAfterAction()
_.defaults options, collection.routes?.view

adminCreateRouteNew = (collection, collectionName) ->
Expand All @@ -110,7 +110,7 @@ adminCreateRouteNewOptions = (collection, collectionName) ->
Session.set 'admin_subtitle', 'Create new'
Session.set 'admin_collection_page', 'new'
Session.set 'admin_collection_name', collectionName
collection.routes?.new?.onAfterAction
collection.routes?.new?.onAfterAction()
data: ->
admin_collection: adminCollectionObject collectionName
_.defaults options, collection.routes?.new
Expand All @@ -126,7 +126,7 @@ adminCreateRouteEditOptions = (collection, collectionName) ->
controller: "AdminController"
waitOn: ->
Meteor.subscribe 'adminCollectionDoc', collectionName, parseID(@params._id)
collection.routes?.edit?.waitOn
collection.routes?.edit?.waitOn?()
action: ->
@render()
onAfterAction: ->
Expand All @@ -136,7 +136,7 @@ adminCreateRouteEditOptions = (collection, collectionName) ->
Session.set 'admin_collection_name', collectionName
Session.set 'admin_id', parseID(@params._id)
Session.set 'admin_doc', adminCollectionObject(collectionName).findOne _id : parseID(@params._id)
collection.routes?.edit?.onAfterAction
collection.routes?.edit?.onAfterAction()
data: ->
admin_collection: adminCollectionObject collectionName
_.defaults options, collection.routes?.edit
Expand Down
4 changes: 2 additions & 2 deletions lib/client/html/admin_templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ <h4>Change Password</h4>
</template>

<template name="adminEditBtn">
<a href="{{path}}" class="hidden-xs btn btn-xs btn-primary"><i class="fa fa-pencil"></i></a>
<a href="{{path}}" class="visible-xs btn btn-sm btn-primary"><i class="fa fa-pencil"></i> Edit</a>
<a href="{{path}}" class="hidden-xs btn btn-xs btn-primary"><i class="fa fa-pencil " style="color: {{color}}"></i></a>
<a href="{{path}}" class="visible-xs btn btn-sm btn-primary"><i class="fa fa-pencil" style="color: {{color}}"></i> Edit</a>
</template>

<template name="adminDeleteBtn">
Expand Down
9 changes: 8 additions & 1 deletion lib/client/js/templates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ Template.AdminDashboardView.rendered = ->

Template.AdminDashboardView.helpers
hasDocuments: ->
AdminCollectionsCount.findOne({collection: Session.get 'admin_collection_name'})?.count > 0
Blaze._globalHelpers.adminCollectionCount(Session.get 'admin_collection_name') > 0
newPath: ->
Router.path 'adminDashboard' + Session.get('admin_collection_name') + 'New'

Template.adminEditBtn.helpers
path: ->
Router.path "adminDashboard" + Session.get('admin_collection_name') + "Edit", _id: @_id

color: ->
order = Orders.findOne(this._id)
if order? && order.manualState in ['red', 'yellow', 'green']
order.manualState
else
'inherit'
2 changes: 1 addition & 1 deletion lib/server/publish.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Meteor.publish 'adminCollectionsCount', ->
table = AdminTables[name]
ready = false
selector = if table.selector then table.selector(self.userId) else {}
handles.push table.collection.find().observeChanges
handles.push table.collection.find(selector, {fields: {}}).observeChanges
added: ->
count += 1
ready and self.changed 'adminCollectionsCount', id, {count: count}
Expand Down