Skip to content

Commit

Permalink
Better interface for admins & redirects.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkravets committed Oct 10, 2015
1 parent eeb375e commit 60359bb
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 67 deletions.
3 changes: 1 addition & 2 deletions app/assets/javascripts/ants.coffee
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#= require chr/admins
#= require chr/redirects
#= require_tree ./ants
53 changes: 53 additions & 0 deletions app/assets/javascripts/ants/admins.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class @AntsAdmins
constructor: (title='Admins', apiPath='/admin') ->
config =
title: title
showWithParent: true

arrayStore: new RailsArrayStore({
resource: 'admin'
path: "#{ apiPath }/admins"
sortBy: 'name'
searchable: true
})

formSchema:
name:
type: 'string'
required: true
label: "Name"
placeholder: 'Full name'
onInitialize: (input) ->
if input.object
input.$el.removeClass 'input-required'
input.config.disabled = true
input._add_disabled()

email:
type: 'string'
required: true
placeholder: 'Email'

onInitialize: (input) ->
if input.object
input.$el.removeClass 'input-required'
input.config.disabled = true
input._add_disabled()

input.$actions =$ "<span class='input-actions'></span>"
input.$avatarBtn =$ "<a href='https://en.gravatar.com/' target='_blank'>Update avatar</a>"
input.$label.append input.$actions
input.$actions.append input.$avatarBtn

password:
type: 'password'
required: true
placeholder: 'Password'
onInitialize: (input) ->
if input.object
input.$el.removeClass 'input-required'
input.$label.html 'Change Password'
input.config.placeholder = 'Type new password here to update the current one'
input._add_placeholder()

return config
23 changes: 23 additions & 0 deletions app/assets/javascripts/ants/redirects.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class @AntsRedirects
constructor: (title='Redirects', apiPath='/admin') ->
config =
title: title
showWithParent: true

onViewShow: (view) ->
if view.object
view.$linkBtn =$ "<a href='#{ view.object.path_from }' class='link open' target='_blank'>Open</a>"
view.$header.append view.$linkBtn

arrayStore: new RailsArrayStore({
resource: 'redirect'
path: "#{ apiPath }/redirects"
sortBy: 'path_from'
searchable: true
})

formSchema:
path_from: { type: 'string', label: 'From', placeholder: '/redirect-from-path', required: true }
path_to: { type: 'url', label: 'To', placeholder: '/redirect-to-path', required: true }

return config
44 changes: 0 additions & 44 deletions app/assets/javascripts/chr/admins.coffee

This file was deleted.

20 changes: 0 additions & 20 deletions app/assets/javascripts/chr/redirects.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion lib/ants/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ants
VERSION = "0.2.2"
VERSION = "0.2.3"
end

0 comments on commit 60359bb

Please sign in to comment.