./lib/helios/frontend/javascripts/helios/views.coffee in helios-0.2.1 vs ./lib/helios/frontend/javascripts/helios/views.coffee in helios-0.2.2
- old
+ new
@@ -1,7 +1,14 @@
+class Helios.Views.Navigation extends Backbone.View
+ template: JST['navigation']
+ el: "[role='navigation']"
+
+ render: =>
+ @$el.html(@template())
+
class Helios.Views.Entities extends Backbone.View
- template: JST['entities']
+ template: JST['data/entities']
el: "[role='main']"
events:
'change #entities': ->
window.app.navigate(@$el.find("#entities").val(), {trigger: true})
@@ -34,11 +41,11 @@
@$el.find("#datagrid").html(@datagrid.el)
@
class Helios.Views.Devices extends Backbone.View
- template: JST['devices']
+ template: JST['push-notification/devices']
el: "[role='main']"
events:
'keyup form.filter input': 'filter'
@@ -51,23 +58,23 @@
})
render: =>
@$el.html(@template())
- @composeView ?= new Helios.Views.Compose()
- @composeView.render()
+ # @composeView ?= new Helios.Views.Compose()
+ # @composeView.render()
@$el.find("#datagrid").html(@datagrid.el)
@
filter: (e) ->
e.preventDefault()
@collection.query = $(e.target).val()
@collection.fetch()
class Helios.Views.Compose extends Backbone.View
- template: JST['compose']
+ template: JST['push-notification/compose']
el: "#compose-modal"
events:
'submit form': 'submit'
'click button#send': 'submit'
@@ -106,11 +113,12 @@
tokens = undefined
if $("input[name='recipients']:checked").val() == "specified"
tokens = [$form.find("#tokens").val()]
- $.ajax("/message"
+ $.ajax(
+ url:"/message"
type: "POST"
dataType: "json"
data: {
tokens: tokens,
payload: payload
@@ -179,11 +187,11 @@
$time.attr("datetime", Date.now().toISOString())
$time.find(".time").text(Date.now().toString("HH:mm"))
$time.find(".date").text(Date.now().toString("dddd, MMMM d"))
class Helios.Views.Receipts extends Backbone.View
- template: JST['receipts']
+ template: JST['in-app-purchase/receipts']
el: "[role='main']"
events:
'keyup form.filter input': 'filter'
@@ -205,11 +213,11 @@
e.preventDefault()
@collection.query = $(e.target).val()
@collection.fetch()
class Helios.Views.Passes extends Backbone.View
- template: JST['passes']
+ template: JST['passbook/passes']
el: "[role='main']"
events:
'keyup form.filter input': 'filter'
@@ -229,5 +237,71 @@
filter: (e) ->
e.preventDefault()
@collection.query = $(e.target).val()
@collection.fetch()
+
+class Helios.Views.Issues extends Backbone.View
+ template: JST['newsstand/issues']
+ el: "[role='main']"
+
+ events:
+ 'keyup form.filter input': 'filter'
+
+ initialize: ->
+ @datagrid = new Backbone.Datagrid({
+ collection: @collection,
+ columns: @collection.fields,
+ paginated: true,
+ perPage: 20
+ })
+
+ $.ajax(
+ url: Helios.services['newsstand'] + "/issues/new",
+ type: "HEAD",
+ error: ->
+ $(".auxiliary button").prop('disabled', true)
+ )
+
+ render: =>
+ @$el.html(@template())
+ @$el.find("#datagrid").html(@datagrid.el)
+
+ @newView ?= new Helios.Views.NewIssue()
+ @newView.render()
+
+ @
+
+ filter: (e) ->
+ e.preventDefault()
+ @collection.query = $(e.target).val()
+ @collection.fetch()
+
+class Helios.Views.NewIssue extends Backbone.View
+ template: JST['newsstand/new']
+ el: "#new-issue-modal"
+
+ events:
+ 'submit form': 'submit'
+ 'click button#create': 'submit'
+
+ render: ->
+ @$el.html(@template())
+
+ @
+
+ submit: ->
+ $form = @$el.find("form#new")
+ console.log($form.find("input[type='file']"))
+ $.ajax(
+ url: $form.attr("action")
+ type: "POST"
+ dataType: "json"
+ data: $form.serializeMultipart()
+ cache: false
+ contentType: false
+ processData: false
+ success: (data) ->
+ console.log("Success", data)
+ error: (data) ->
+ console.log("Failure", data)
+ )