Start working on a folders support.

This commit is contained in:
Paulo Gustavo Veiga 2012-05-23 21:54:03 -03:00
parent 9bc4504aea
commit b21fd642a5
5 changed files with 136 additions and 18 deletions

View File

@ -41,15 +41,19 @@ public class MindmapController extends BaseController {
} }
@RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"application/json", "text/html", "application/xml"}) @RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"application/json", "text/html", "application/xml"})
public ModelAndView getMindmaps() throws IOException { public ModelAndView getMindmaps(@RequestParam(required = false) String q) throws IOException {
final User user = com.wisemapping.security.Utils.getUser(); final User user = com.wisemapping.security.Utils.getUser();
final MindmapFilter filter = MindmapFilter.parse(q);
final List<MindmapUser> mapsByUser = mindmapService.getMindmapUserByUser(user); final List<MindmapUser> mapsByUser = mindmapService.getMindmapUserByUser(user);
final List<MindMap> mindmaps = new ArrayList<MindMap>(); final List<MindMap> mindmaps = new ArrayList<MindMap>();
for (MindmapUser mindmapUser : mapsByUser) { for (MindmapUser mindmapUser : mapsByUser) {
mindmaps.add(mindmapUser.getMindMap()); final MindMap mindmap = mindmapUser.getMindMap();
if (filter.accept(mindmap, user)) {
mindmaps.add(mindmap);
}
} }
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps); final RestMindmapList restMindmapList = new RestMindmapList(mindmaps);
return new ModelAndView("mapsView", "list", restMindmapList); return new ModelAndView("mapsView", "list", restMindmapList);
} }

View File

@ -0,0 +1,56 @@
package com.wisemapping.rest;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public enum MindmapFilter {
ALL("all") {
@Override
public boolean accept(@NotNull MindMap mindmap, @NotNull User user) {
return true;
}
},
MY_MAPS("my_maps") {
@Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) {
return mindmap.getOwner().equals(user);
}
},
SHARED_WITH_ME("shared_with_me") {
@Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) {
return !MY_MAPS.accept(mindmap, user);
}
},
PUBLIC("public") {
@Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) {
return mindmap.isPublic();
}
};
private String id;
MindmapFilter(@NotNull String id) {
this.id = id;
}
static public MindmapFilter parse(@Nullable String valueStr) {
MindmapFilter result = ALL;
final MindmapFilter[] values = MindmapFilter.values();
for (MindmapFilter value : values) {
if (value.id.equals(valueStr)) {
result = value;
break;
}
}
return result;
}
abstract boolean accept(@NotNull MindMap mindmap, @NotNull User user);
}

View File

@ -85,6 +85,11 @@ input#selectAll {
.dataTables_filter { .dataTables_filter {
float:right; float:right;
} }
#mindmapListTable th {
padding: 4px;
}
/* Pagination Styles */ /* Pagination Styles */
#paginateContainer { #paginateContainer {
height:40px; height:40px;
@ -162,3 +167,10 @@ input#selectAll {
height:50px; height:50px;
white-space:nowrap; white-space:nowrap;
} }
#foldersContainer {
width: 15%;
float: left;
margin-right: 2%;
margin-top: 80px
}

View File

@ -18,6 +18,46 @@ jQuery.fn.dataTableExt.oSort['es_date-desc'] = function(a, b) {
return ((x < y) ? 1 : ((x > y) ? -1 : 0)); return ((x < y) ? 1 : ((x > y) ? -1 : 0));
}; };
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
if (typeof sNewSource != 'undefined' && sNewSource != null) {
oSettings.sAjaxSource = sNewSource;
}
this.oApi._fnProcessingDisplay(oSettings, true);
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];
this.oApi._fnServerParams(oSettings, aData);
oSettings.fnServerData(oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable(oSettings);
/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn(oSettings.sAjaxDataProp)(json) : json;
for (var i = 0; i < aData.length; i++) {
that.oApi._fnAddData(oSettings, aData[i]);
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that.fnDraw();
if (typeof bStandingRedraw != 'undefined' && bStandingRedraw === true) {
oSettings._iDisplayStart = iStart;
that.fnDraw(false);
}
that.oApi._fnProcessingDisplay(oSettings, false);
/* Callback user function - for event handlers etc */
if (typeof fnCallback == 'function' && fnCallback != null) {
fnCallback(oSettings);
}
}, oSettings);
}
jQuery.fn.dataTableExt.selectAllMaps = function() { jQuery.fn.dataTableExt.selectAllMaps = function() {
var total = $('.select input:checkbox[id!="selectAll"]').size(); var total = $('.select input:checkbox[id!="selectAll"]').size();
var selected = $('.select input:checked[id!="selectAll"]').size(); var selected = $('.select input:checked[id!="selectAll"]').size();

View File

@ -52,12 +52,6 @@
return '<a href="c/map/' + obj.aData.id + '/edit.htm">' + obj.aData.title + '</a>'; return '<a href="c/map/' + obj.aData.id + '/edit.htm">' + obj.aData.title + '</a>';
} }
}, },
{
bVisible: false,
bSearchable : false,
sTitle : "Owner Email",
mDataProp: "ownerEmail"
},
{ {
sTitle : "Owner", sTitle : "Owner",
mDataProp :"owner" mDataProp :"owner"
@ -78,7 +72,7 @@
oLanguage : { oLanguage : {
"sSearch" : "", "sSearch" : "",
"sInfo" : "_START_-_END_ of _TOTAL_", "sInfo" : "_START_-_END_ of _TOTAL_",
"sEmptyTable": "Hey, you don't have any mindmap. Go ahead and create one clicking on the 'New' button !!!" "sEmptyTable": "No mindmap available for the selected filter criteria."
}, },
bStateSave:true bStateSave:true
}); });
@ -233,12 +227,24 @@
$("#actionButtons .tagMap").click(function() { $("#actionButtons .tagMap").click(function() {
}); });
$("#actionButtons .share").click(function() {
});
$("#actionButtons .tags").click(function() { $("#actionButtons .tags").click(function() {
}); });
$('#foldersContainer li').click(function(event) {
// Deselect previous option ...
$('#foldersContainer li').removeClass('active');
$('#foldersContainer i').removeClass('icon-white');
// Select the new item ...
var dataTable = $('#mindmapListTable').dataTable();
$(this).addClass('active').filter('i').addClass('icon-white');
// Reload the table data ...
dataTable.fnReloadAjax("../service/maps?q=" + $(this).attr('data-filter'));
event.preventDefault();
});
}); });
// Register time update functions .... // Register time update functions ....
@ -265,13 +271,13 @@
</div> </div>
<div id="mindmapListContainer"> <div id="mindmapListContainer">
<div style="width: 15%;float: left;margin-right: 2%;margin-top: 80px"> <div id="foldersContainer">
<ul class="nav nav-list"> <ul class="nav nav-list">
<li class="nav-header">Folders</li> <li class="nav-header">Folders</li>
<li data-filter="all" class="active"><a href="#"><i class="icon-inbox"></i> All</a></li>
<li class="active"><a href="#"><i class="icon-inbox"></i> All</a></li> <li data-filter="my_maps" ><a href="#"><i class="icon-user"></i> My Maps</a></li>
<li><a href="#"><i class="icon-share"></i> Shared With Me</a></li> <li data-filter="shared_with_me"><a href="#"><i class="icon-share"></i> Shared With Me</a></li>
<li><a href="#"><i class="icon-globe"></i> Public Maps</a></li> <li data-filter="public"><a href="#"><i class="icon-globe"></i> Public Maps</a></li>
</ul> </ul>
</div> </div>