Add readOnly support to the mindmapList.

This commit is contained in:
Paulo Gustavo Veiga 2012-06-17 12:24:09 -03:00
parent 5e67811dcf
commit 26766fdbc6
13 changed files with 256 additions and 321 deletions

View File

@ -38,158 +38,173 @@ mindplot.widget.Menu = new Class({
// Create panels ... // Create panels ...
var designerModel = designer.getModel(); var designerModel = designer.getModel();
var fontFamilyModel = {
getValue: function() { var fontFamilyBtn = $('fontFamily');
var nodes = designerModel.filterSelectedTopics(); if (fontFamilyBtn) {
var result = null; var fontFamilyModel = {
for (var i = 0; i < nodes.length; i++) { getValue: function() {
var fontFamily = nodes[i].getFontFamily(); var nodes = designerModel.filterSelectedTopics();
if (result != null && result != fontFamily) { var result = null;
result = null; for (var i = 0; i < nodes.length; i++) {
break; var fontFamily = nodes[i].getFontFamily();
if (result != null && result != fontFamily) {
result = null;
break;
}
result = fontFamily;
} }
result = fontFamily; return result;
},
setValue: function(value) {
designer.changeFontFamily(value);
} }
return result; };
}, this._toolbarElems.push(new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel));
this._registerTooltip('fontFamily', "Text font");
}
setValue: function(value) { var fontSizeBtn = $('fontSize');
designer.changeFontFamily(value); if (fontSizeBtn) {
var fontSizeModel = {
} getValue: function() {
}; var nodes = designerModel.filterSelectedTopics();
this._toolbarElems.push(new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel)); var result = null;
this._registerTooltip('fontFamily', "Text font"); for (var i = 0; i < nodes.length; i++) {
var fontSize = nodes[i].getFontSize();
if (result != null && result != fontSize) {
var fontSizeModel = { result = null;
getValue: function() { break;
var nodes = designerModel.filterSelectedTopics(); }
var result = null; result = fontSize;
for (var i = 0; i < nodes.length; i++) {
var fontSize = nodes[i].getFontSize();
if (result != null && result != fontSize) {
result = null;
break;
} }
result = fontSize; return result;
},
setValue: function(value) {
designer.changeFontSize(value);
} }
return result; };
}, this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel));
setValue: function(value) { this._registerTooltip('fontSize', "Text size");
designer.changeFontSize(value); }
}
};
this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel));
this._registerTooltip('fontSize', "Text size");
var topicShapeBtn = $('topicShapeBtn');
var topicShapeModel = { if (topicShapeBtn) {
getValue: function() { var topicShapeModel = {
var nodes = designerModel.filterSelectedTopics(); getValue: function() {
var result = null; var nodes = designerModel.filterSelectedTopics();
for (var i = 0; i < nodes.length; i++) { var result = null;
var shapeType = nodes[i].getShapeType(); for (var i = 0; i < nodes.length; i++) {
if (result != null && result != shapeType) { var shapeType = nodes[i].getShapeType();
result = null; if (result != null && result != shapeType) {
break; result = null;
break;
}
result = shapeType;
} }
result = shapeType; return result;
},
setValue: function(value) {
designer.changeTopicShape(value);
} }
return result; };
}, this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel));
setValue: function(value) { this._registerTooltip('topicShape', "Topic shape");
designer.changeTopicShape(value); }
}
};
this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel));
this._registerTooltip('topicShape', "Topic shape");
// Create icon panel dialog ...
var topicIconModel = {
getValue: function() {
return null;
},
setValue: function(value) {
designer.addIconType(value);
}
};
this._toolbarElems.push(new mindplot.widget.IconPanel('topicIcon', topicIconModel));
this._registerTooltip('topicIcon', "Icon");
var topicIconBtn = $('topicIcon');
if (topicIconBtn) {
// Create icon panel dialog ...
var topicIconModel = {
getValue: function() {
return null;
},
setValue: function(value) {
designer.addIconType(value);
}
};
this._toolbarElems.push(new mindplot.widget.IconPanel('topicIcon', topicIconModel));
this._registerTooltip('topicIcon', "Icon");
}
// Topic color item ... // Topic color item ...
var topicColorModel = var topicColorBtn = $('topicColor');
{ if (topicColorBtn) {
getValue : function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getBackgroundColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
return result;
},
setValue : function (hex) {
designer.changeBackgroundColor(hex);
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl));
this._registerTooltip('topicColor', "Topic color");
var topicColorModel = {
getValue : function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getBackgroundColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
return result;
},
setValue : function (hex) {
designer.changeBackgroundColor(hex);
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl));
this._registerTooltip('topicColor', "Topic color");
}
// Border color item ... // Border color item ...
var borderColorModel = var topicBorderBtn = $('topicBorder');
{ if (topicBorderBtn) {
getValue : function() { var borderColorModel =
var nodes = designerModel.filterSelectedTopics(); {
var result = null; getValue : function() {
for (var i = 0; i < nodes.length; i++) { var nodes = designerModel.filterSelectedTopics();
var color = nodes[i].getBorderColor(); var result = null;
if (result != null && result != color) { for (var i = 0; i < nodes.length; i++) {
result = null; var color = nodes[i].getBorderColor();
break; if (result != null && result != color) {
result = null;
break;
}
result = color;
} }
result = color; return result;
},
setValue : function (hex) {
designer.changeBorderColor(hex);
} }
return result; };
}, this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
setValue : function (hex) { this._registerTooltip('topicBorder', "Border color");
designer.changeBorderColor(hex); }
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
this._registerTooltip('topicBorder', "Border color");
// Font color item ... // Font color item ...
var fontColorModel = var fontColorBtn = $('fontColor');
{ if (fontColorBtn) {
getValue : function() { var fontColorModel =
var result = null; {
var nodes = designerModel.filterSelectedTopics(); getValue : function() {
for (var i = 0; i < nodes.length; i++) { var result = null;
var color = nodes[i].getFontColor(); var nodes = designerModel.filterSelectedTopics();
if (result != null && result != color) { for (var i = 0; i < nodes.length; i++) {
result = null; var color = nodes[i].getFontColor();
break; if (result != null && result != color) {
result = null;
break;
}
result = color;
} }
result = color; return result;
},
setValue : function (hex) {
designer.changeFontColor(hex);
} }
return result; };
}, this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl));
setValue : function (hex) { this._registerTooltip('fontColor', "Text color");
designer.changeFontColor(hex); }
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl));
this._registerTooltip('fontColor', "Text color");
this._addButton('export', false, false, function() { this._addButton('export', false, false, function() {
var reqDialog = new MooDialog.Request('c/iframeWrapper.htm?url=c/maps/' + mapId + "/exportf", null, var reqDialog = new MooDialog.Request('c/iframeWrapper.htm?url=c/maps/' + mapId + "/exportf", null,
@ -208,7 +223,7 @@ mindplot.widget.Menu = new Class({
this._registerTooltip('export', "Export"); this._registerTooltip('export', "Export");
this._addButton('print', false, false, function() { this._addButton('print', false, false, function() {
window.open('c/map/' + mapId + '/print'); window.open('c/maps/' + mapId + '/print');
}); });
this._registerTooltip('print', "Print"); this._registerTooltip('print', "Print");

View File

@ -20,6 +20,7 @@ package com.wisemapping.ncontroller;
import com.wisemapping.filter.UserAgent; import com.wisemapping.filter.UserAgent;
import com.wisemapping.model.CollaborationRole;
import com.wisemapping.model.MindMap; import com.wisemapping.model.MindMap;
import com.wisemapping.security.Utils; import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService; import com.wisemapping.service.MindmapService;
@ -61,13 +62,6 @@ public class MindmapController {
return "mindmapPrint"; return "mindmapPrint";
} }
@RequestMapping(value = "maps/{id}/view")
public String showViewPage(@PathVariable int id, @NotNull Model model) {
final MindMap mindmap = findMindmap(id);
model.addAttribute("mindmap", mindmap);
return "mindmapPrint";
}
@RequestMapping(value = "maps/{id}/export") @RequestMapping(value = "maps/{id}/export")
public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException { public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException {
final MindMap mindmap = findMindmap(id); final MindMap mindmap = findMindmap(id);
@ -124,23 +118,27 @@ public class MindmapController {
return "mindmapList"; return "mindmapList";
} }
@RequestMapping(value = "maps/{id}/edit") @RequestMapping(value = "maps/{id}/edit", method = RequestMethod.GET)
public ModelAndView editMap(@PathVariable int id, @NotNull HttpServletRequest request) { public String showMindmapEditorPage(@PathVariable int id, @NotNull Model model) {
ModelAndView view; final MindMapBean mindmapBean = findMindmapBean(id);
final UserAgent userAgent = UserAgent.create(request); final MindMap mindmap = mindmapBean.getDelegated();
if (userAgent.needsGCF()) {
view = new ModelAndView("gcfPluginNeeded");
// view.addObject(MINDMAP_ID_PARAMETER, mindmapId);
} else {
final MindMapBean mindmap = findMindmapBean(id); String result;
view = new ModelAndView("mindmapEditor", "mindmap", mindmap); if (mindmap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR)) {
view.addObject("editorTryMode", false); model.addAttribute("mindmap", mindmapBean);
final boolean showHelp = isWelcomeMap(mindmap); result = "mindmapEditor";
view.addObject("showHelp", showHelp); } else {
view.addObject("user", Utils.getUser()); result = "redirect:view";
} }
return view; return result;
}
@RequestMapping(value = "maps/{id}/view", method = RequestMethod.GET)
public String showMindmapViewerPage(@PathVariable int id, @NotNull Model model) {
final MindMapBean mindmapBean = findMindmapBean(id);
model.addAttribute("mindmap", mindmapBean);
model.addAttribute("readOnlyMode", true);
return "mindmapEditor";
} }
@RequestMapping(value = "maps/{id}/embed") @RequestMapping(value = "maps/{id}/embed")

View File

@ -1,72 +0,0 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.view;
import java.util.Calendar;
import java.util.Locale;
import java.text.DateFormat;
public class HistoryBean
{
private Calendar historyTime;
private String author;
private int mindmapId;
private int historyId;
public HistoryBean() {}
public HistoryBean(int mindmapId,int historyId,String author, Calendar time)
{
this.mindmapId = mindmapId;
this.author = author;
this.historyTime = time;
this.historyId = historyId;
}
public Calendar getHistoryTime() {
return historyTime;
}
public String getCreation(Locale locale)
{
return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.DEFAULT,locale).format(historyTime.getTime());
}
public void setHistoryTime(Calendar historyTime) {
this.historyTime = historyTime;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getMindMapId()
{
return mindmapId;
}
public int getHistoryId()
{
return historyId;
}
}

View File

@ -31,11 +31,11 @@ import java.util.*;
public class MindMapBean { public class MindMapBean {
private MindMap mindMap; private MindMap mindMap;
private List<CollaboratorBean> viewers; private List<CollaboratorBean> viewers;
private List<CollaboratorBean> colaborators; private List<CollaboratorBean> collaborators;
public MindMapBean(final MindMap mindmap) { public MindMapBean(final MindMap mindmap) {
this.mindMap = mindmap; this.mindMap = mindmap;
this.colaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
} }
@ -64,7 +64,7 @@ public class MindMapBean {
} }
public List<CollaboratorBean> getCollaborators() { public List<CollaboratorBean> getCollaborators() {
return colaborators; return collaborators;
} }
public String getLastEditor() { public String getLastEditor() {
@ -96,7 +96,7 @@ public class MindMapBean {
} }
public int getCountCollaborators() { public int getCountCollaborators() {
return colaborators != null ? colaborators.size() : 0; return collaborators != null ? collaborators.size() : 0;
} }
public int getCountViewers() { public int getCountViewers() {
@ -135,4 +135,12 @@ public class MindMapBean {
return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.OWNER); return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.OWNER);
} }
public boolean isEditor() {
return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR);
}
public MindMap getDelegated(){
return mindMap;
}
} }

View File

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View File

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 148 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,22 +0,0 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @Todo: This must be reviewed ...
function displayLoading() {
$('headerLoading').style.visibility = 'visible';
}

View File

@ -25,13 +25,13 @@
</c:choose> </c:choose>
<div class="header_languages"> <div class="header_languages">
<div class="header_language_flag"> <div class="header_language_flag">
<a href="?language=en"><img src="../images/uk.gif" alt="English"></a> <a href="?language=en"><img src="../images/flag-uk.gif" alt="English"></a>
</div> </div>
<div class="header_language_flag"> <div class="header_language_flag">
<a href="?language=fr"><img src="../images/fr.gif" alt="Frances"></a> <a href="?language=fr"><img src="../images/flag-fr.gif" alt="Frances"></a>
</div> </div>
<div class="header_language_flag"> <div class="header_language_flag">
<a href="?language=es"><img src="../images/es.gif" alt="Espanol"></a> <a href="?language=es"><img src="../images/flag-es.gif" alt="Español"></a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -36,6 +36,7 @@
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/{id}/document"); options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/{id}/document");
var userOptions = ${mindmap.properties}; var userOptions = ${mindmap.properties};
options.zoom = userOptions.zoom; options.zoom = userOptions.zoom;
options.readOnly = ${!!readOnlyMode};
// Set map id ... // Set map id ...
options.mapId = mapId; options.mapId = mapId;

View File

@ -2,27 +2,28 @@
<div id="toolbar"> <div id="toolbar">
<div id="persist" class="buttonContainer"> <div id="persist" class="buttonContainer">
<div id="save" class="buttonOn"> <c:if test="${!readOnlyMode}">
<img src="../images/save.png"/> <div id="save" class="buttonOn">
</div> <img src="../images/save.png"/>
<div id="discard" class="buttonOn"> </div>
<img src="../images/discard.png"/> <div id="discard" class="buttonOn">
</div> <img src="../images/discard.png"/>
</div>
</c:if>
<div id="print" class="buttonOn"> <div id="print" class="buttonOn">
<img src="../images/print.png"/> <img src="../images/print.png"/>
</div> </div>
<div id="export" class="buttonOn">
<img src="../images/export.png"/>
</div>
</div> </div>
<div id="edit" class="buttonContainer"> <c:if test="${!readOnlyMode}">
<div id="undoEdition" class="buttonOn"> <div id="edit" class="buttonContainer">
<img src="../images/undo.png"/> <div id="undoEdition" class="buttonOn">
<img src="../images/undo.png"/>
</div>
<div id="redoEdition" class="buttonOn">
<img src="../images/redo.png"/>
</div>
</div> </div>
<div id="redoEdition" class="buttonOn"> </c:if>
<img src="../images/redo.png"/>
</div>
</div>
<div id="zoom" class="buttonContainer"> <div id="zoom" class="buttonContainer">
<div id="zoomIn" class="buttonOn"> <div id="zoomIn" class="buttonOn">
<img src="../images/zoom-in.png"/> <img src="../images/zoom-in.png"/>
@ -31,55 +32,56 @@
<img src="../images/zoom-out.png"/> <img src="../images/zoom-out.png"/>
</div> </div>
</div> </div>
<div id="node" class="buttonContainer"> <c:if test="${!readOnlyMode}">
<div id="topicShape" class="buttonExtOn"> <div id="node" class="buttonContainer">
<img src="../images/topic-shape.png"/> <div id="topicShape" class="buttonExtOn">
<img src="../images/topic-shape.png"/>
</div>
<div id="addTopic" class="buttonOn">
<img src="../images/topic-add.png"/>
</div>
<div id="deleteTopic" class="buttonOn">
<img src="../images/topic-delete.png"/>
</div>
<div id="topicBorder" class="buttonExtOn">
<img src="../images/topic-border.png"/>
</div>
<div id="topicColor" class="buttonExtOn">
<img src="../images/topic-color.png"/>
</div>
<div id="topicIcon" class="buttonExtOn">
<img src="../images/topic-icon.png"/>
</div>
<div id="topicNote" class="buttonOn">
<img src="../images/topic-note.png"/>
</div>
<div id="topicLink" class="buttonOn">
<img src="../images/topic-link.png"/>
</div>
<div id="topicRelation" class="buttonOn">
<img src="../images/topic-relation.png"/>
</div>
</div> </div>
<div id="addTopic" class="buttonOn"> <div id="font" class="buttonContainer">
<img src="../images/topic-add.png"/> <div id="fontFamily" class="buttonOn">
<img src="../images/font-type.png"/>
</div>
<div id="fontSize" class="buttonExtOn">
<img src="../images/font-size.png"/>
</div>
<div id="fontBold" class="buttonOn">
<img src="../images/font-bold.png"/>
</div>
<div id="fontItalic" class="buttonOn">
<img src="../images/font-italic.png"/>
</div>
<div id="fontColor" class="buttonExtOn">
<img src="../images/font-color.png"/>
</div>
</div> </div>
<div id="deleteTopic" class="buttonOn"> </c:if>
<img src="../images/topic-delete.png"/>
</div>
<div id="topicBorder" class="buttonExtOn">
<img src="../images/topic-border.png"/>
</div>
<div id="topicColor" class="buttonExtOn">
<img src="../images/topic-color.png"/>
</div>
<div id="topicIcon" class="buttonExtOn">
<img src="../images/topic-icon.png"/>
</div>
<div id="topicNote" class="buttonOn">
<img src="../images/topic-note.png"/>
</div>
<div id="topicLink" class="buttonOn">
<img src="../images/topic-link.png"/>
</div>
<div id="topicRelation" class="buttonOn">
<img src="../images/topic-relation.png"/>
</div>
</div>
<div id="font" class="buttonContainer">
<div id="fontFamily" class="buttonOn">
<img src="../images/font-type.png"/>
</div>
<div id="fontSize" class="buttonExtOn">
<img src="../images/font-size.png"/>
</div>
<div id="fontBold" class="buttonOn">
<img src="../images/font-bold.png"/>
</div>
<div id="fontItalic" class="buttonOn">
<img src="../images/font-italic.png"/>
</div>
<div id="fontColor" class="buttonExtOn">
<img src="../images/font-color.png"/>
</div>
</div>
<div id="collaboration" class="buttonContainer"> <div id="collaboration" class="buttonContainer">
<c:if test="${mindmap.owner}"> <c:if test="${mindmap.owner && !readOnlyMode}">
<div id="shareIt" class="buttonOn"> <div id="shareIt" class="buttonOn">
<img src="../images/share.png"/> <img src="../images/share.png"/>
</div> </div>
@ -87,9 +89,14 @@
<img src="../images/public.png"/> <img src="../images/public.png"/>
</div> </div>
</c:if> </c:if>
<div id="history" class="buttonOn"> <div id="export" class="buttonOn">
<img src="../images/history.png"/> <img src="../images/export.png"/>
</div> </div>
<c:if test="${!readOnlyMode}">
<div id="history" class="buttonOn">
<img src="../images/history.png"/>
</div>
</c:if>
</div> </div>
<div id="headerNotifier"></div> <div id="headerNotifier"></div>
</div> </div>

View File

@ -18,7 +18,7 @@
<!--jQuery DataTables--> <!--jQuery DataTables-->
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="js/mymaps.js"></script> <script type="text/javascript" language="javascript" src="js/mindmapList.js"></script>
<!-- Update timer plugging --> <!-- Update timer plugging -->
<script type="text/javascript" language="javascript" src="js/jquery.timeago.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.timeago.js"></script>