Skip to content

Commit 5777b9c

Browse files
committed
Selecting a row in the site map then edit it.
* Store the selected content object and its parent section. * Selected a row highlights it.
1 parent b998188 commit 5777b9c

File tree

6 files changed

+58
-12
lines changed

6 files changed

+58
-12
lines changed

app/assets/javascripts/cms/new-sitemap.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,45 @@
33

44
// Code for working with the new sitemap structure.
55

6+
var Sitemap = function() {
7+
};
8+
Sitemap.prototype.selectSection = function(section) {
9+
this.selectedSection = section;
10+
};
11+
12+
Sitemap.prototype.clearSelection = function() {
13+
$('.active').removeClass('active');
14+
disableButtons();
15+
};
16+
17+
// Selecting a row in the sitemap
18+
// @param [HtmlElement] row The selected row.
19+
Sitemap.prototype.selectRow = function(row) {
20+
this.clearSelection();
21+
this.selectedRow = row;
22+
if (this.selectedRow.data('type') != 'section') {
23+
this.selectSection(this.selectedRow.parents('ul:first')[0]);
24+
}else {
25+
this.selectSection(this.selectedRow[0]);
26+
}
27+
28+
// Highlight the row as selected.
29+
this.selectedRow.parents('li:first').addClass('active');
30+
};
31+
var sitemap = new Sitemap();
32+
33+
var disableButtons = function() {
34+
$('a.button').addClass('disabled').click(function() {
35+
return false;
36+
});
37+
};
38+
39+
// Enable buttons for Selecting pages
40+
$(function() {
41+
$('.selectable').click(function() {
42+
sitemap.selectRow($(this));
43+
});
44+
});
645

746
// Make sections collapsible/expandable
847
$(function() {

app/assets/stylesheets/cms/sitemap.css.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ body {
7878
}
7979

8080

81+
82+

app/views/cms/section_nodes/_link.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<%# Renders an instance of this in the sitemap. %>
2-
<li><a href="#"><%= icon "share" %> <%= link.name %>
1+
<li><a href="#" class="selectable"><%= icon "share" %> <%= link.name %>
32
<span class="span1">
43
<%= content_tag "i", "", class: access_icon %>
54
</span>

app/views/cms/section_nodes/_page.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<li><a href="#"><%= icon "file" %> <%= page.name %>
1+
<li><a href="#" class="selectable"><%= icon "file" %> <%= page.name %>
22
<span class="span1">
33
<%= content_tag "span", "H", class: "status phidden" if page.hidden? %>
44
<%= content_tag "i", "", class: access_icon %>

app/views/cms/section_nodes/_section.html.erb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
collapse = section.root? ? "" : "collapse"
33
icon_name = section.root? ? "home" : "folder-close"
44
%>
5-
<li><%= content_tag("a", href: "#", data: {toggle: 'collapse', target: "#section#{section.id}"}) do %>
5+
<li>
6+
<%= content_tag("a", href: "#", class: 'selectable',
7+
data: {toggle: 'collapse',
8+
target: "#section#{section.id}",
9+
type: 'section'
10+
}) do %>
611
<%= icon(icon_name) %> <%= section.name %>
712
<span class="span1">
813
<%= content_tag "i", "", class: access_status(section, @public_sections) %>

todo_ui_Revamp.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ Tasks:
22

33
## UI Merge
44

5-
* Sitemap - Reverse engineer sitemap from new files
6-
* New Button - Figure out styling issue
7-
*
5+
* Enable the buttons for pages
6+
* Enable the buttons for everything else.
7+
* Remove (or center) the lock/unlock icon for the root section
8+
* Keep open/closed state of sitemap
9+
* Delete/merge js/cms/sitemap.js.erb
10+
* Move/drag/drop sections
11+
* Enable buttons correctly based on selected item
12+
* Selecting the root section should not change its icon or expand/collapse it.
13+
814
##
915

1016

@@ -16,11 +22,6 @@ Current Task:
1622

1723
* Implement implied features (Search/Notifications)
1824

19-
20-
### Notes
21-
22-
* Multiple versions of jquery being loaded breaks things.
23-
2425
## Admin Menu
2526
* Reduce the different admin layouts (why are there so many?)
2627
* Need to highlight active tab

0 commit comments

Comments
 (0)