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 ...
var designerModel = designer.getModel();
var fontFamilyModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var fontFamily = nodes[i].getFontFamily();
if (result != null && result != fontFamily) {
result = null;
break;
var fontFamilyBtn = $('fontFamily');
if (fontFamilyBtn) {
var fontFamilyModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
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) {
designer.changeFontFamily(value);
}
};
this._toolbarElems.push(new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel));
this._registerTooltip('fontFamily', "Text font");
var fontSizeModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var fontSize = nodes[i].getFontSize();
if (result != null && result != fontSize) {
result = null;
break;
var fontSizeBtn = $('fontSize');
if (fontSizeBtn) {
var fontSizeModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var fontSize = nodes[i].getFontSize();
if (result != null && result != fontSize) {
result = null;
break;
}
result = fontSize;
}
result = fontSize;
return result;
},
setValue: function(value) {
designer.changeFontSize(value);
}
return result;
},
setValue: function(value) {
designer.changeFontSize(value);
}
};
this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel));
this._registerTooltip('fontSize', "Text size");
};
this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel));
this._registerTooltip('fontSize', "Text size");
}
var topicShapeModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var shapeType = nodes[i].getShapeType();
if (result != null && result != shapeType) {
result = null;
break;
var topicShapeBtn = $('topicShapeBtn');
if (topicShapeBtn) {
var topicShapeModel = {
getValue: function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var shapeType = nodes[i].getShapeType();
if (result != null && result != shapeType) {
result = null;
break;
}
result = shapeType;
}
result = shapeType;
return result;
},
setValue: function(value) {
designer.changeTopicShape(value);
}
return result;
},
setValue: function(value) {
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");
};
this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel));
this._registerTooltip('topicShape', "Topic shape");
}
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 ...
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");
var topicColorBtn = $('topicColor');
if (topicColorBtn) {
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 ...
var borderColorModel =
{
getValue : function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getBorderColor();
if (result != null && result != color) {
result = null;
break;
var topicBorderBtn = $('topicBorder');
if (topicBorderBtn) {
var borderColorModel =
{
getValue : function() {
var nodes = designerModel.filterSelectedTopics();
var result = null;
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getBorderColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
result = color;
return result;
},
setValue : function (hex) {
designer.changeBorderColor(hex);
}
return result;
},
setValue : function (hex) {
designer.changeBorderColor(hex);
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
this._registerTooltip('topicBorder', "Border color");
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
this._registerTooltip('topicBorder', "Border color");
}
// Font color item ...
var fontColorModel =
{
getValue : function() {
var result = null;
var nodes = designerModel.filterSelectedTopics();
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getFontColor();
if (result != null && result != color) {
result = null;
break;
var fontColorBtn = $('fontColor');
if (fontColorBtn) {
var fontColorModel =
{
getValue : function() {
var result = null;
var nodes = designerModel.filterSelectedTopics();
for (var i = 0; i < nodes.length; i++) {
var color = nodes[i].getFontColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
result = color;
return result;
},
setValue : function (hex) {
designer.changeFontColor(hex);
}
return result;
},
setValue : function (hex) {
designer.changeFontColor(hex);
}
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl));
this._registerTooltip('fontColor', "Text color");
};
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl));
this._registerTooltip('fontColor', "Text color");
}
this._addButton('export', false, false, function() {
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._addButton('print', false, false, function() {
window.open('c/map/' + mapId + '/print');
window.open('c/maps/' + mapId + '/print');
});
this._registerTooltip('print', "Print");

View File

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

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 {
private MindMap mindMap;
private List<CollaboratorBean> viewers;
private List<CollaboratorBean> colaborators;
private List<CollaboratorBean> collaborators;
public MindMapBean(final 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);
}
@ -64,7 +64,7 @@ public class MindMapBean {
}
public List<CollaboratorBean> getCollaborators() {
return colaborators;
return collaborators;
}
public String getLastEditor() {
@ -96,7 +96,7 @@ public class MindMapBean {
}
public int getCountCollaborators() {
return colaborators != null ? colaborators.size() : 0;
return collaborators != null ? collaborators.size() : 0;
}
public int getCountViewers() {
@ -135,4 +135,12 @@ public class MindMapBean {
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>
<div class="header_languages">
<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 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 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>

View File

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

View File

@ -2,27 +2,28 @@
<div id="toolbar">
<div id="persist" class="buttonContainer">
<div id="save" class="buttonOn">
<img src="../images/save.png"/>
</div>
<div id="discard" class="buttonOn">
<img src="../images/discard.png"/>
</div>
<c:if test="${!readOnlyMode}">
<div id="save" class="buttonOn">
<img src="../images/save.png"/>
</div>
<div id="discard" class="buttonOn">
<img src="../images/discard.png"/>
</div>
</c:if>
<div id="print" class="buttonOn">
<img src="../images/print.png"/>
</div>
<div id="export" class="buttonOn">
<img src="../images/export.png"/>
</div>
</div>
<div id="edit" class="buttonContainer">
<div id="undoEdition" class="buttonOn">
<img src="../images/undo.png"/>
<c:if test="${!readOnlyMode}">
<div id="edit" class="buttonContainer">
<div id="undoEdition" class="buttonOn">
<img src="../images/undo.png"/>
</div>
<div id="redoEdition" class="buttonOn">
<img src="../images/redo.png"/>
</div>
</div>
<div id="redoEdition" class="buttonOn">
<img src="../images/redo.png"/>
</div>
</div>
</c:if>
<div id="zoom" class="buttonContainer">
<div id="zoomIn" class="buttonOn">
<img src="../images/zoom-in.png"/>
@ -31,55 +32,56 @@
<img src="../images/zoom-out.png"/>
</div>
</div>
<div id="node" class="buttonContainer">
<div id="topicShape" class="buttonExtOn">
<img src="../images/topic-shape.png"/>
<c:if test="${!readOnlyMode}">
<div id="node" class="buttonContainer">
<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 id="addTopic" class="buttonOn">
<img src="../images/topic-add.png"/>
<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="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 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>
</c:if>
<div id="collaboration" class="buttonContainer">
<c:if test="${mindmap.owner}">
<c:if test="${mindmap.owner && !readOnlyMode}">
<div id="shareIt" class="buttonOn">
<img src="../images/share.png"/>
</div>
@ -87,9 +89,14 @@
<img src="../images/public.png"/>
</div>
</c:if>
<div id="history" class="buttonOn">
<img src="../images/history.png"/>
<div id="export" class="buttonOn">
<img src="../images/export.png"/>
</div>
<c:if test="${!readOnlyMode}">
<div id="history" class="buttonOn">
<img src="../images/history.png"/>
</div>
</c:if>
</div>
<div id="headerNotifier"></div>
</div>

View File

@ -18,7 +18,7 @@
<!--jQuery DataTables-->
<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 -->
<script type="text/javascript" language="javascript" src="js/jquery.timeago.js"></script>