Better handling of path or location for administration links.

This commit is contained in:
2017-03-24 21:56:48 +01:00
parent 21e75a6492
commit 307a87eaf4
5 changed files with 39 additions and 13 deletions

View File

@@ -90,6 +90,10 @@ feature -- Element change
children := lst children := lst
end end
lst.force (lnk) lst.force (lnk)
if not is_expanded then
set_expandable (True)
set_collapsed (True)
end
end end
remove_link (lnk: CMS_LINK) remove_link (lnk: CMS_LINK)
@@ -102,6 +106,8 @@ feature -- Element change
lst.prune_all (lnk) lst.prune_all (lnk)
if lst.is_empty then if lst.is_empty then
children := Void children := Void
set_collapsed (False)
set_expandable (False)
end end
end end
end end
@@ -110,6 +116,12 @@ feature -- Element change
-- Set `children' to `lst'. -- Set `children' to `lst'.
do do
children := lst 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 ensure
children_set: children = lst children_set: children = lst
end end
@@ -184,6 +196,6 @@ feature {NONE} -- Implementation
invariant invariant
note 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)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end end

View File

@@ -256,13 +256,17 @@ feature -- Access: url
administration_path (a_relative_path: detachable READABLE_STRING_8): STRING_8 administration_path (a_relative_path: detachable READABLE_STRING_8): STRING_8
do do
create Result.make_from_string (setup.administration_base_path) 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 /= Void then
if a_relative_path.is_empty then
Result.append_character ('/')
else
if a_relative_path[1] /= '/' then if a_relative_path[1] /= '/' then
Result.append_character ('/') Result.append_character ('/')
end end
Result.append (a_relative_path) Result.append (a_relative_path)
end end
end end
end
administration_path_location (a_relative_location: detachable READABLE_STRING_8): STRING_8 administration_path_location (a_relative_location: detachable READABLE_STRING_8): STRING_8
require require
@@ -270,10 +274,16 @@ feature -- Access: url
do do
create Result.make_from_string (administration_base_path_location) create Result.make_from_string (administration_base_path_location)
if a_relative_location /= Void then if a_relative_location /= Void then
if a_relative_location.is_empty then
Result.append_character ('/') Result.append_character ('/')
else
if a_relative_location[1] /= '/' then
Result.append_character ('/')
end
Result.append (a_relative_location) Result.append (a_relative_location)
end end
end end
end
feature {NONE} -- Url implementation. feature {NONE} -- Url implementation.
@@ -282,9 +292,11 @@ feature {NONE} -- Url implementation.
feature -- CMS links 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 do
Result := local_link (a_title, administration_path_location (a_location)) Result := local_link (a_title, administration_path_location (a_relative_location))
end end
local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK

View File

@@ -160,7 +160,7 @@ feature -- Settings: router
l_api.logger.put_debug (generator + ".setup_router_for_administration", Void) l_api.logger.put_debug (generator + ".setup_router_for_administration", Void)
-- Configure root of api handler. -- 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. -- Include routes from modules.
across across

View File

@@ -105,7 +105,7 @@ feature -- HTTP Methods
s.append ("</li>%N") s.append ("</li>%N")
end end
s.append ("</ul>") s.append ("</ul>")
s.append ("<div>Back to the " + r.link ("Administration", api.administration_path (""), Void) + " ...</div>") s.append ("<div>Back to the " + r.link ("Administration", api.administration_path (Void), Void) + " ...</div>")
r.set_main_content (s) r.set_main_content (s)
end end
r.set_title (r.translation ("CMS Installation ...", Void)) r.set_title (r.translation ("CMS Installation ...", Void))

View File

@@ -1333,9 +1333,11 @@ feature -- Generation
feature -- Helpers: cms link 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 do
Result := api.administration_link (a_title, a_location) Result := api.administration_link (a_title, a_relative_location)
end end
local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK local_link (a_title: READABLE_STRING_GENERAL; a_location: READABLE_STRING_8): CMS_LOCAL_LINK