From 171f8d72a91d2cd23f1cca09158dfa561521c3a9 Mon Sep 17 00:00:00 2001 From: Mark Severson Date: Thu, 12 Sep 2013 11:49:51 -0600 Subject: [PATCH] miscellaneous fixes and style tweaks for pages behaviors: - general - prevent links to unauthorized pages (course/pages index) - index page - add loading indicator - show page - prevent unauthorized attempts to query sequence footer - edit page - editing with the sidebar works again - removed the toolbar - will not prompt to save an unedited page (when the user doesn't have rights to modify the title) style: - sticky toolbar - margins (left & right) - drop shadow - index page - hide empty toolbar - fills the entire page width & height - inner border color - prevent sort headers from wrapping - show page - hide empty toolbar - adjusted margins for the 'Front Page' label - sequence footer - faster animation - print stylesheet test plan: * ensure all wiki draft state pages still function correctly closes CNVS-7756 Change-Id: I3b13a672b4caacb3a41fa28a1b1c2b29d35140f3 Reviewed-on: https://gerrit.instructure.com/24308 Reviewed-by: Jeremy Stanley Tested-by: Jenkins Product-Review: Matt Goodwin QA-Review: August Thornton QA-Review: Hannah Bottalla --- .../bundles/wiki_page_edit.coffee | 2 +- .../bundles/wiki_page_index.coffee | 9 +- .../bundles/wiki_page_show.coffee | 2 +- .../views/wiki/WikiPageEditView.coffee | 10 ++- .../views/wiki/WikiPageIndexView.coffee | 16 +++- .../views/wiki/WikiPageView.coffee | 1 + app/controllers/application_controller.rb | 5 +- app/controllers/wiki_pages_controller.rb | 18 ++-- .../base/module_sequence_footer.scss | 10 ++- app/stylesheets/g_wiki.sass | 90 +++++++++++++------ app/views/jst/wiki/WikiPage.handlebars | 2 + app/views/jst/wiki/WikiPageEdit.handlebars | 30 +------ app/views/jst/wiki/WikiPageIndex.handlebars | 8 ++ 13 files changed, 124 insertions(+), 79 deletions(-) diff --git a/app/coffeescripts/bundles/wiki_page_edit.coffee b/app/coffeescripts/bundles/wiki_page_edit.coffee index 2f520421d41..6478f7a8873 100644 --- a/app/coffeescripts/bundles/wiki_page_edit.coffee +++ b/app/coffeescripts/bundles/wiki_page_edit.coffee @@ -4,7 +4,7 @@ require [ 'compiled/views/wiki/WikiPageEditView' ], ($, WikiPage, WikiPageEditView) -> - $('body').addClass('pages edit') + $('body').addClass('edit') wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string diff --git a/app/coffeescripts/bundles/wiki_page_index.coffee b/app/coffeescripts/bundles/wiki_page_index.coffee index e3159178943..b25442f8147 100644 --- a/app/coffeescripts/bundles/wiki_page_index.coffee +++ b/app/coffeescripts/bundles/wiki_page_index.coffee @@ -10,7 +10,7 @@ require [ $.cookie('deleted_page_title', null, path: '/') $.flashMessage htmlEscape(I18n.t('notices.page_deleted', 'The page "%{title}" has been deleted.', title: deleted_page_title)) - $('body').addClass('pages index') + $('body').addClass('index').removeClass('with-right-side') view = new WikiPageIndexView collection: new WikiPageCollection @@ -19,10 +19,7 @@ require [ WIKI_RIGHTS: ENV.WIKI_RIGHTS view.collection.setParams sort:'title', per_page:30 - view.collection.fetch().then -> - view.fetched = true - # Re-render after fetching is complete, but only if there are no pages in the collection - view.render() if view.collection.models.length == 0 - $('#content').append(view.$el) + view.collection.fetch() + $('#content').append(view.$el) view.render() diff --git a/app/coffeescripts/bundles/wiki_page_show.coffee b/app/coffeescripts/bundles/wiki_page_show.coffee index bad66492560..6063cd13657 100644 --- a/app/coffeescripts/bundles/wiki_page_show.coffee +++ b/app/coffeescripts/bundles/wiki_page_show.coffee @@ -5,7 +5,7 @@ require [ 'compiled/jquery/ModuleSequenceFooter' ], ($, WikiPage, WikiPageView) -> - $('body').addClass('pages show') + $('body').addClass('show') wikiPage = new WikiPage ENV.WIKI_PAGE, revision: ENV.WIKI_PAGE_REVISION, contextAssetString: ENV.context_asset_string diff --git a/app/coffeescripts/views/wiki/WikiPageEditView.coffee b/app/coffeescripts/views/wiki/WikiPageEditView.coffee index cd58b0d3545..cd86cdad192 100644 --- a/app/coffeescripts/views/wiki/WikiPageEditView.coffee +++ b/app/coffeescripts/views/wiki/WikiPageEditView.coffee @@ -104,10 +104,11 @@ define [ # @api private initWikiSidebar: -> unless wikiSidebar.inited + $wikiPageBody = @$wikiPageBody $ -> wikiSidebar.init() $.scrollSidebar() - wikiSidebar.attachToEditor(@$wikiPageBody).show() + wikiSidebar.attachToEditor($wikiPageBody).show() $ -> wikiSidebar.show() @@ -131,11 +132,14 @@ define [ errors hasUnsavedChanges: -> + json = @toJSON() + formData = @getFormData() oldBody = @model.get('body') || '' newBody = formData.body || '' - oldTitle = @model.get('title') || '' - newTitle = formData.title || '' + if json.CAN.EDIT_TITLE + oldTitle = @model.get('title') || '' + newTitle = formData.title || '' return (oldBody != newBody) || (oldTitle != newTitle) unsavedWarning: -> diff --git a/app/coffeescripts/views/wiki/WikiPageIndexView.coffee b/app/coffeescripts/views/wiki/WikiPageIndexView.coffee index 92022887ef5..d44fbb9eeb0 100644 --- a/app/coffeescripts/views/wiki/WikiPageIndexView.coffee +++ b/app/coffeescripts/views/wiki/WikiPageIndexView.coffee @@ -43,6 +43,14 @@ define [ [@contextName, @contextId] = splitAssetString(@contextAssetString) if @contextAssetString @itemViewOptions.contextName = @contextName + @collection.on 'fetch', => + unless @fetched + @fetched = true + @render() + @collection.on 'fetched:last', => + @fetchedLast = true + @render() + @collection.on 'sortChanged', @sortChanged @currentSortField = @collection.currentSortField @@ -87,7 +95,7 @@ define [ @$el.hide() $('body').removeClass('index') - $('body').addClass('edit') + $('body').addClass('edit with-right-side') @editModel = new WikiPage {editing_roles: @default_editing_roles}, contextAssetString: @contextAssetString @editView = new WikiPageEditView @@ -107,7 +115,7 @@ define [ @editView.$el.remove() wikiSidebar.hide() - $('body').removeClass('edit') + $('body').removeClass('edit with-right-side') $('body').addClass('index') @$el.show() @@ -117,5 +125,7 @@ define [ CREATE: !!@WIKI_RIGHTS.create_page MANAGE: !!@WIKI_RIGHTS.manage PUBLISH: !!@WIKI_RIGHTS.manage && @contextName == 'courses' - json.fetched = @fetched + json.CAN.VIEW_TOOLBAR = json.CAN.CREATE + json.fetched = !!@fetched + json.fetchedLast = !!@fetchedLast json diff --git a/app/coffeescripts/views/wiki/WikiPageView.coffee b/app/coffeescripts/views/wiki/WikiPageView.coffee index 01121525c02..9ec6cf1664c 100644 --- a/app/coffeescripts/views/wiki/WikiPageView.coffee +++ b/app/coffeescripts/views/wiki/WikiPageView.coffee @@ -82,4 +82,5 @@ define [ DELETE: !!@PAGE_RIGHTS.delete READ_REVISIONS: !!@PAGE_RIGHTS.read_revisions ACCESS_GEAR_MENU: !!@PAGE_RIGHTS.delete || !!@PAGE_RIGHTS.read_revisions + json.CAN.VIEW_TOOLBAR = json.CAN.VIEW_PAGES || json.CAN.PUBLISH || json.CAN.UPDATE_CONTENT || json.CAN.ACCESS_GEAR_MENU json diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5791963de60..b45eac86018 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -440,7 +440,10 @@ class ApplicationController < ActionController::Base end set_badge_counts_for(@context, @current_user, @current_enrollment) assign_localizer if @context.present? - add_crumb(@context.short_name, named_context_url(@context, :context_url), :id => "crumb_#{@context.asset_string}") if @context && @context.respond_to?(:short_name) + if @context && @context.respond_to?(:short_name) + crumb_url = named_context_url(@context, :context_url) if @context.grants_right?(@current_user, :read) + add_crumb(@context.short_name, crumb_url) + end end end diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 50a81ba65f2..786b8cb4125 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -24,12 +24,17 @@ class WikiPagesController < ApplicationController before_filter :set_js_rights, :only => [:pages_index, :show_page, :edit_page] before_filter :set_js_wiki_data, :only => [:pages_index, :show_page, :edit_page] add_crumb(proc { t '#crumbs.wiki_pages', "Pages"}) do |c| + url = nil context = c.instance_variable_get('@context') - if context.draft_state_enabled? - c.send :polymorphic_path, [context, :pages] - else - c.send :named_context_url, c.instance_variable_get("@context"), :context_wiki_pages_url + current_user = c.instance_variable_get('@current_user') + if context.grants_right?(current_user, :read) + if context.draft_state_enabled? + url = c.send :polymorphic_path, [context, :pages] + else + url = c.send :named_context_url, c.instance_variable_get("@context"), :context_wiki_pages_url + end end + url end before_filter { |c| c.active_tab = "pages" } @@ -234,8 +239,11 @@ class WikiPagesController < ApplicationController hash[:WIKI_PAGE_REVISION] = (current_version = @page.versions.current) ? current_version.number : nil hash[:WIKI_PAGE_SHOW_PATH] = polymorphic_path([@context, :named_page], :wiki_page_id => @page) hash[:WIKI_PAGE_EDIT_PATH] = polymorphic_path([@context, :edit_named_page], :wiki_page_id => @page) - hash[:COURSE_ID] = @context.id if @context.is_a? Course hash[:WIKI_PAGE_HISTORY_PATH] = polymorphic_path([@context, @page, :wiki_page_revisions]) + + if @context.is_a?(Course) + hash[:COURSE_ID] = @context.id if @context.grants_right?(@current_user, :read) + end end js_env hash diff --git a/app/stylesheets/base/module_sequence_footer.scss b/app/stylesheets/base/module_sequence_footer.scss index f223ccf3938..d075c9d5d14 100644 --- a/app/stylesheets/base/module_sequence_footer.scss +++ b/app/stylesheets/base/module_sequence_footer.scss @@ -55,6 +55,12 @@ $button-hover: #dee5ea; } .module-sequence-padding, .module-sequence-footer{ - animation: module-sequence-footer-animation 1.25s; - -webkit-animation: module-sequence-footer-animation 1.25s; + animation: module-sequence-footer-animation 1s; + -webkit-animation: module-sequence-footer-animation 1s; +} + +@media print { + .module-sequence-padding, .module-sequence-footer { + display: none; + } } diff --git a/app/stylesheets/g_wiki.sass b/app/stylesheets/g_wiki.sass index e4cb0cecbe1..2bf2fd4242f 100644 --- a/app/stylesheets/g_wiki.sass +++ b/app/stylesheets/g_wiki.sass @@ -12,44 +12,49 @@ $unpublished-icon-color: #b4b7ba $border-color: #c1c7cf $border-radius: 3px +$pages-border: 1px solid #c1c7cf +$pages-dashed-border: 1px dashed #c1c7cf +$pages-inner-border: 1px solid #e1e3e4 + $index-background: #e8ecef $item-background: #ffffff $item-hover-background: #eef7ff $shadow: 0 1px 0 rgba(0,0,0,0.15) +$table-shadow: 0 1px 0 #dde0e4 + +.pages .sticky + position: fixed + z-index: 1000 + top: 0px + left: 0px + right: 0px + margin-left: 1px + background: white + height: 33px + max-width: $max_main_width + border-color: $menu-border-color + +.pages.with-left-side .sticky + margin-left: $left_side_width + 1px +.pages.with-right-side .sticky + margin-right: $right_side_width + 1px .pages - .sticky - position: fixed - z-index: 1000 - top: 0px - left: 0px - margin-left: $left_side_width + 1px - background: white - height: 33px - max-width: $max_main_width - border-color: $menu-border-color - - &.sticky-toolbar - right: 0px - - &.sticky-toolbar-with-right-side - right: $right_side_width + 1px - min-width: $min_main_width - 2px - #breadcrumbs - :border-bottom 1px solid $border-color + :border-bottom $pages-border .header-bar-outer-container :height 64px .header-bar-container - :box-shadow $shadow :height 64px .page-changed-alert :overflow hidden :height 0 .page-changed-alert .alert :border-radius 0 + .header-bar + :box-shadow $shadow .header-bar-outer-container.page-changed :height 103px @@ -62,12 +67,16 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) .page-changed-alert :margin -1px 0 0 0 - :border-bottom 1px solid $border-color + :border-bottom $pages-border + :box-shadow $shadow :height 39px :animation page-changed-alert 1.15s :-webkit-animation page-changed-alert 1.15s .pages.index + #main + :background $index-background + .index-content-container :margin-top 1px @@ -84,10 +93,10 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) :width 270px .index-content - :background $index-background :padding 0 1em 1em .table + :margin-bottom 0 :border-collapse separate :border-spacing 0 td, th @@ -102,6 +111,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) :cursor pointer :user-select none :color inherit + :white-space nowrap i :color #ccc a.sort-field:hover @@ -113,6 +123,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) :color black .table thead + :background $index-background tr :height 40px th @@ -137,18 +148,21 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) :text-decoration inherit :color inherit td:first-child - :border-left 1px solid $border-color + :border-left $pages-border td:last-child - :border-right 1px solid $border-color + :border-right $pages-border tr:first-child + td + :border-top $pages-border td:first-child :border-top-left-radius $border-radius td:last-child :border-top-right-radius $border-radius tr:last-child td - :border-bottom 1px solid $border-color + :border-bottom $pages-border + :box-shadow $table-shadow td:first-child :border-bottom-left-radius $border-radius td:last-child @@ -157,7 +171,7 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) td :font-size 11px :color $subdued-text-color - :border-top 1px solid $border-color + :border-top $pages-inner-border .wiki-page-link :font-size 13px @@ -174,12 +188,32 @@ $shadow: 0 1px 0 rgba(0,0,0,0.15) :color $unpublished-icon-color .table .no-pages .no-pages-cell - :border 1px dashed $border-color + :border $pages-dashed-border + + .loading + :text-align center + :color #8f9295 + + img + :margin-top -3px + :opacity 0.75 + &.loading + :border 1px solid transparent + &.loading-more + :border $pages-dashed-border + :border-top-width 0 + :border-bottom-left-radius $border-radius + :border-bottom-right-radius $border-radius + :margin-top 1px + :padding 4px 12px + :background #f4f6f8 .pages.show .header-bar .publish-button - :margin 0 12px + :margin 0 12px 0 0 + .front-page.label + :margin 6px 12px 6px 0 .show-content :padding 15px 25px diff --git a/app/views/jst/wiki/WikiPage.handlebars b/app/views/jst/wiki/WikiPage.handlebars index 4f6fdae1f79..d83ddcc3226 100644 --- a/app/views/jst/wiki/WikiPage.handlebars +++ b/app/views/jst/wiki/WikiPage.handlebars @@ -1,3 +1,4 @@ +{{#if CAN.VIEW_TOOLBAR}}
@@ -35,6 +36,7 @@
+{{/if}}

{{title}}

diff --git a/app/views/jst/wiki/WikiPageEdit.handlebars b/app/views/jst/wiki/WikiPageEdit.handlebars index 7f186755c39..25586f5d3df 100644 --- a/app/views/jst/wiki/WikiPageEdit.handlebars +++ b/app/views/jst/wiki/WikiPageEdit.handlebars @@ -1,31 +1,3 @@ -
-
-
-
-
-
- {{#if CAN.PUBLISH}} - {{#if published}} - {{#t 'buttons.unpublish'}}Published{{/t}} - {{else}} - {{#t 'buttons.publish'}}Unpublished{{/t}} - {{/if}} - {{/if}} - {{#if CAN.DELETE}} - - - {{#t 'toolbar_menu.settings'}}Settings{{/t}} - - - {{/if}} -
-
- -
-
-
{{#if CAN.EDIT_TITLE}} @@ -37,7 +9,7 @@ {{#t "#editor.switch_views"}}Switch Views{{/t}}
- + {{#if CAN.EDIT_ROLES}}
diff --git a/app/views/jst/wiki/WikiPageIndex.handlebars b/app/views/jst/wiki/WikiPageIndex.handlebars index 2703c957841..4a01fa6c17b 100644 --- a/app/views/jst/wiki/WikiPageIndex.handlebars +++ b/app/views/jst/wiki/WikiPageIndex.handlebars @@ -1,3 +1,4 @@ +{{#if CAN.VIEW_TOOLBAR}}
@@ -9,6 +10,7 @@
+{{/if}}
@@ -38,5 +40,11 @@ {{/if}} + {{#unless fetchedLast}} +
+ + {{#unless fetched}}{{#t 'loading'}}Loading ...{{/t}}{{else}}{{#t 'loading_more'}}Loading more ...{{/t}}{{/unless}} +
+ {{/unless}}