From 8e989ec08f7e17141d74328fe6739657e456583f Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 23:17:19 +0100 Subject: [PATCH] Got the level history view set up as before, but better --- app/templates/editor/level/versions.jade | 11 -------- app/templates/kinds/versions.jade | 24 ---------------- app/templates/modal/versions.jade | 25 +++++++++++++++++ app/views/editor/article/versions.coffee | 9 ------ app/views/editor/article/versions_view.coffee | 9 ++++++ app/views/editor/level/versions.coffee | 9 ------ app/views/editor/level/versions_view.coffee | 28 ++----------------- .../versions_modal.coffee} | 11 ++++---- 8 files changed, 43 insertions(+), 83 deletions(-) delete mode 100644 app/templates/editor/level/versions.jade delete mode 100755 app/templates/kinds/versions.jade create mode 100755 app/templates/modal/versions.jade delete mode 100644 app/views/editor/article/versions.coffee create mode 100644 app/views/editor/article/versions_view.coffee delete mode 100644 app/views/editor/level/versions.coffee rename app/views/{kinds/VersionsView.coffee => modal/versions_modal.coffee} (81%) diff --git a/app/templates/editor/level/versions.jade b/app/templates/editor/level/versions.jade deleted file mode 100644 index b40c7b6f0..000000000 --- a/app/templates/editor/level/versions.jade +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/templates/kinds/versions.jade b/app/templates/kinds/versions.jade deleted file mode 100755 index a7db6039f..000000000 --- a/app/templates/kinds/versions.jade +++ /dev/null @@ -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() \ No newline at end of file diff --git a/app/templates/modal/versions.jade b/app/templates/modal/versions.jade new file mode 100755 index 000000000..d91fb1e8e --- /dev/null +++ b/app/templates/modal/versions.jade @@ -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 \ No newline at end of file diff --git a/app/views/editor/article/versions.coffee b/app/views/editor/article/versions.coffee deleted file mode 100644 index 2c3ac5d47..000000000 --- a/app/views/editor/article/versions.coffee +++ /dev/null @@ -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' \ No newline at end of file diff --git a/app/views/editor/article/versions_view.coffee b/app/views/editor/article/versions_view.coffee new file mode 100644 index 000000000..59b8b1f9c --- /dev/null +++ b/app/views/editor/article/versions_view.coffee @@ -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' \ No newline at end of file diff --git a/app/views/editor/level/versions.coffee b/app/views/editor/level/versions.coffee deleted file mode 100644 index 88d8c990d..000000000 --- a/app/views/editor/level/versions.coffee +++ /dev/null @@ -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' \ No newline at end of file diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee index 7f5cc2afd..90245bc67 100644 --- a/app/views/editor/level/versions_view.coffee +++ b/app/views/editor/level/versions_view.coffee @@ -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" \ No newline at end of file + super options, ID, require 'models/Level' \ No newline at end of file diff --git a/app/views/kinds/VersionsView.coffee b/app/views/modal/versions_modal.coffee similarity index 81% rename from app/views/kinds/VersionsView.coffee rename to app/views/modal/versions_modal.coffee index e686d6129..8845c577a 100755 --- a/app/views/kinds/VersionsView.coffee +++ b/app/views/modal/versions_modal.coffee @@ -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