diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee
index 6abc2599..f6a6c3e5 100644
--- a/app/coffee/modules/wiki/main.coffee
+++ b/app/coffee/modules/wiki/main.coffee
@@ -147,43 +147,64 @@ module.controller("WikiDetailController", WikiDetailController)
#############################################################################
-## Wiki User Info Directive
+## Wiki Summary Directive
#############################################################################
-WikiUserInfoDirective = ($log) ->
+WikiSummaryDirective = ($log) ->
template = _.template("""
-
-
-
- last modification
- <%- name %>
+
+ -
+ <%- totalEditions %>
+ times
edited
+
+ -
+ <%- lastModifiedDate %>
+ last
edit
+
+ -
+
+
+
+ last modification
+ <%- user.name %>
+
+
""")
- link = ($scope, $el, $attrs) ->
- if not $attrs.ngModel?
- return $log.error "WikiUserDirective: no ng-model attr is defined"
-
+ link = ($scope, $el, $attrs, $model) ->
render = (wiki) ->
if not $scope.usersById?
- $log.error "WikiUserDirective requires userById set in scope."
+ $log.error "WikiSummaryDirective requires userById set in scope."
else
user = $scope.usersById[wiki.last_modifier]
- if user is undefined
- ctx = {name: "unknown", imgurl: "/images/unnamed.png"}
- else
- ctx = {name: user.full_name_display, imgurl: user.photo}
+ if user is undefined
+ user = {name: "unknown", imgUrl: "/images/unnamed.png"}
+ else
+ user = {name: user.full_name_display, imgUrl: user.photo}
+
+ ctx = {
+ totalEditions: wiki.editions
+ lastModifiedDate: moment(wiki.modified_date).format("DD MMM YYYY HH:mm")
+ user: user
+ }
html = template(ctx)
$el.html(html)
- bindOnce($scope, $attrs.ngModel, render)
+ $scope.$watch $attrs.ngModel, (wikiPage) ->
+ return if not wikiPage
+ render(wikiPage)
+
+ $scope.$on "$destroy", ->
+ $el.off()
return {
link: link
- restrict: "AE"
+ restrict: "EA"
+ require: "ngModel"
}
-module.directive("tgWikiUserInfo", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", WikiUserInfoDirective])
+module.directive("tgWikiSummary", ["$log", WikiSummaryDirective])
#############################################################################
diff --git a/app/partials/views/modules/wiki-summary.jade b/app/partials/views/modules/wiki-summary.jade
deleted file mode 100644
index 5a7871a6..00000000
--- a/app/partials/views/modules/wiki-summary.jade
+++ /dev/null
@@ -1,9 +0,0 @@
-div.summary.wiki-summary(ng-if="wiki.id")
- ul
- li
- span.number(tg-bo-bind="wiki.editions")
- span.description times
edited
- li(ng-if="wiki.modified_date")
- span.number(tg-bo-bind="wiki.modified_date|momentFormat:'DD MMM YYYY HH:mm'")
- span.description last
edit
- li.username-edition(tg-wiki-user-info, ng-model='wiki')
diff --git a/app/partials/wiki.jade b/app/partials/wiki.jade
index 3cf51d3c..565c0b87 100644
--- a/app/partials/wiki.jade
+++ b/app/partials/wiki.jade
@@ -15,8 +15,7 @@ block content
span.green Wiki
span.wiki-title(tg-bo-bind='wikiSlug|unslugify')
- include views/modules/wiki-summary
-
- section.wiki-content(tg-editable-wiki-content ng-model="wiki")
+ div.summary.wiki-summary(tg-wiki-summary, ng-model="wiki", ng-if="wiki.id")
+ section.wiki-content(tg-editable-wiki-content, ng-model="wiki")
tg-attachments(ng-model="wiki", type="wiki_page", ng-if="wiki.id")