From 307a87eaf4bb2adea9861791cbef52a937418856 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 24 Mar 2017 21:56:48 +0100 Subject: [PATCH] Better handling of path or location for administration links. --- library/model/src/link/cms_local_link.e | 14 +++++++++- src/service/cms_api.e | 26 ++++++++++++++----- src/service/cms_execution.e | 4 +-- .../handler/cms_admin_install_handler.e | 2 +- src/service/response/cms_response.e | 6 +++-- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/library/model/src/link/cms_local_link.e b/library/model/src/link/cms_local_link.e index 227a09c..82a393e 100644 --- a/library/model/src/link/cms_local_link.e +++ b/library/model/src/link/cms_local_link.e @@ -90,6 +90,10 @@ feature -- Element change children := lst end lst.force (lnk) + if not is_expanded then + set_expandable (True) + set_collapsed (True) + end end remove_link (lnk: CMS_LINK) @@ -102,6 +106,8 @@ feature -- Element change lst.prune_all (lnk) if lst.is_empty then children := Void + set_collapsed (False) + set_expandable (False) end end end @@ -110,6 +116,12 @@ feature -- Element change -- Set `children' to `lst'. do children := lst + if lst /= Void and then not lst.is_empty then + if not is_expanded then + set_expandable (True) + set_collapsed (True) + end + end ensure children_set: children = lst end @@ -184,6 +196,6 @@ feature {NONE} -- Implementation invariant note - copyright: "2011-2016, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + copyright: "2011-2017, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/src/service/cms_api.e b/src/service/cms_api.e index 4c7ab49..262e02e 100644 --- a/src/service/cms_api.e +++ b/src/service/cms_api.e @@ -256,11 +256,15 @@ feature -- Access: url administration_path (a_relative_path: detachable READABLE_STRING_8): STRING_8 do create Result.make_from_string (setup.administration_base_path) - if a_relative_path /= Void and then not a_relative_path.is_empty then - if a_relative_path[1] /= '/' then + if a_relative_path /= Void then + if a_relative_path.is_empty then Result.append_character ('/') + else + if a_relative_path[1] /= '/' then + Result.append_character ('/') + end + Result.append (a_relative_path) end - Result.append (a_relative_path) end end @@ -270,8 +274,14 @@ feature -- Access: url do create Result.make_from_string (administration_base_path_location) if a_relative_location /= Void then - Result.append_character ('/') - Result.append (a_relative_location) + if a_relative_location.is_empty then + Result.append_character ('/') + else + if a_relative_location[1] /= '/' then + Result.append_character ('/') + end + Result.append (a_relative_location) + end end end @@ -282,9 +292,11 @@ feature {NONE} -- Url implementation. feature -- CMS links - administration_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK + administration_link (a_title: READABLE_STRING_GENERAL; a_relative_location: detachable READABLE_STRING_8): CMS_LOCAL_LINK + require + no_first_slash: a_relative_location = Void or else not a_relative_location.starts_with_general ("/") do - Result := local_link (a_title, administration_path_location (a_location)) + Result := local_link (a_title, administration_path_location (a_relative_location)) end local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK diff --git a/src/service/cms_execution.e b/src/service/cms_execution.e index 0054e0b..bccb96c 100644 --- a/src/service/cms_execution.e +++ b/src/service/cms_execution.e @@ -160,8 +160,8 @@ feature -- Settings: router l_api.logger.put_debug (generator + ".setup_router_for_administration", Void) -- Configure root of api handler. - l_router.set_base_url (l_api.administration_path ("")) - + l_router.set_base_url (l_api.administration_path (Void)) + -- Include routes from modules. across modules as ic diff --git a/src/service/handler/cms_admin_install_handler.e b/src/service/handler/cms_admin_install_handler.e index c696ef0..0eaf680 100644 --- a/src/service/handler/cms_admin_install_handler.e +++ b/src/service/handler/cms_admin_install_handler.e @@ -105,7 +105,7 @@ feature -- HTTP Methods s.append ("%N") end s.append ("") - s.append ("
Back to the " + r.link ("Administration", api.administration_path (""), Void) + " ...
") + s.append ("
Back to the " + r.link ("Administration", api.administration_path (Void), Void) + " ...
") r.set_main_content (s) end r.set_title (r.translation ("CMS Installation ...", Void)) diff --git a/src/service/response/cms_response.e b/src/service/response/cms_response.e index 4c212a7..0d1ffca 100644 --- a/src/service/response/cms_response.e +++ b/src/service/response/cms_response.e @@ -1333,9 +1333,11 @@ feature -- Generation feature -- Helpers: cms link - administration_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK + administration_link (a_title: READABLE_STRING_GENERAL; a_relative_location: detachable READABLE_STRING_8): CMS_LOCAL_LINK + require + no_first_slash: a_relative_location = Void or else not a_relative_location.starts_with_general ("/") do - Result := api.administration_link (a_title, a_location) + Result := api.administration_link (a_title, a_relative_location) end local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK