Got the level history view set up as before, but better

This commit is contained in:
Ruben Vereecken 2014-03-10 23:17:19 +01:00
parent 68b10d9023
commit 8e989ec08f
8 changed files with 43 additions and 83 deletions

View file

@ -1,11 +0,0 @@
extends /templates/modal/modal_base
include /templates/kinds/versions
block modal-header-content
h3(data-i18n="general.version_history") Version History
block modal-body-content
if dataList
+version-history-body()
block modal-footer-content

View file

@ -1,24 +0,0 @@
extends /templates/base
mixin version-history-title()
h3(data-i18n="general.version_history_for") Version History for: #{dataList[0]}
mixin version-history-body()
table.table
tr
th(data-i18n="general.name") Name
th(data-i18n="general.version") Version
th(data-i18n="general.commit_msg") Commit Message
for data in dataList
tr
td
a(href="/editor/#{page}/#{data.slug || data._id}")
| #{data.name}
td #{data.version.major}.#{data.version.minor}
td #{data.commitMessage}
block content
if dataList
+version-history-title()
+version-history-body()

View file

@ -0,0 +1,25 @@
extends /templates/modal/modal_base
block modal-header-content
if dataList
- console.log(dataList[0].name)
h3
span(data-i18n="general.version_history_for") Version History for:
|"#{dataList[0].name}"
block modal-body-content
if dataList
table.table
tr
th(data-i18n="general.name") Name
th(data-i18n="general.version") Version
th(data-i18n="general.commit_msg") Commit Message
for data in dataList
tr
td
a(href="/editor/#{page}/#{data.slug || data._id}")
| #{data.name}
td #{data.version.major}.#{data.version.minor}
td #{data.commitMessage}
block modal-footer-content

View file

@ -1,9 +0,0 @@
VersionsView = require 'views/kinds/VersionsView'
module.exports = class SuperVersionsView extends VersionsView
id: "editor-article-versions-view"
url: "/db/article/"
page: "article"
constructor: (options, @ID) ->
super options, ID, require 'models/Article'

View file

@ -0,0 +1,9 @@
VersionsModalView = require 'views/modal/versions_modal'
module.exports = class ArticleVersionsView extends VersionsModalView
id: 'version-history-modal'
url: "/db/article/"
page: "article"
constructor: (options, @ID) ->
super options, ID, require 'models/Article'

View file

@ -1,9 +0,0 @@
VersionsView = require 'views/kinds/VersionsView'
module.exports = class SuperVersionsView extends VersionsView
id: "editor-level-versions-view"
url: "/db/level/"
page: "level"
constructor: (options, @ID) ->
super options, ID, require 'models/Level'

View file

@ -1,31 +1,9 @@
VersionsView = require 'views/kinds/VersionsView'
ModalView = require 'views/kinds/ModalView'
template = require 'templates/editor/level/versions'
VersionsModalView = require 'views/modal/versions_modal'
module.exports = class ModalVersionsView extends VersionsView
module.exports = class LevelVersionsView extends VersionsModalView
id: 'version-history-modal'
url: "/db/level/"
page: "level"
template: template
startsLoading: true
className: "modal fade"
closeButton: true
closesOnClickOutside: true
modalWidthPercent: null
shortcuts:
'esc': 'hide'
constructor: (options, @ID) ->
super options, ID, require 'models/Level'
_.extend @, ModalView
ModalView.prototype.constructor options
getRenderData: (context={}) ->
context = super(context)
context.closeButton = true
context
hide: ->
@$el.removeClass('fade').modal "hide"

View file

@ -1,5 +1,5 @@
View = require 'views/kinds/RootView'
template = require 'templates/kinds/versions'
ModalView = require 'views/kinds/ModalView'
template = require 'templates/modal/versions'
tableTemplate = require 'templates/kinds/table'
class VersionsViewCollection extends Backbone.Collection
@ -10,14 +10,14 @@ class VersionsViewCollection extends Backbone.Collection
@url = url + levelID + '/versions'
@model = model
module.exports = class SuperVersionsView extends View
module.exports = class VersionsModalView extends ModalView
template: template
startsLoading: true
# needs to be overwritten by child
id: ""
url = ""
page = ""
url: ""
page: ""
constructor: (options, @ID, @model) ->
super options
@ -38,4 +38,5 @@ module.exports = class SuperVersionsView extends View
context = super(context)
context.page = @page
context.dataList = (m.attributes for m in @collection.models) if @collection
console.debug context
context