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,6 +38,9 @@ mindplot.widget.Menu = new Class({
// Create panels ... // Create panels ...
var designerModel = designer.getModel(); var designerModel = designer.getModel();
var fontFamilyBtn = $('fontFamily');
if (fontFamilyBtn) {
var fontFamilyModel = { var fontFamilyModel = {
getValue: function() { getValue: function() {
var nodes = designerModel.filterSelectedTopics(); var nodes = designerModel.filterSelectedTopics();
@ -60,8 +63,10 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel)); this._toolbarElems.push(new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel));
this._registerTooltip('fontFamily', "Text font"); this._registerTooltip('fontFamily', "Text font");
}
var fontSizeBtn = $('fontSize');
if (fontSizeBtn) {
var fontSizeModel = { var fontSizeModel = {
getValue: function() { getValue: function() {
var nodes = designerModel.filterSelectedTopics(); var nodes = designerModel.filterSelectedTopics();
@ -82,8 +87,10 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel)); this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel));
this._registerTooltip('fontSize', "Text size"); this._registerTooltip('fontSize', "Text size");
}
var topicShapeBtn = $('topicShapeBtn');
if (topicShapeBtn) {
var topicShapeModel = { var topicShapeModel = {
getValue: function() { getValue: function() {
var nodes = designerModel.filterSelectedTopics(); var nodes = designerModel.filterSelectedTopics();
@ -104,8 +111,10 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel)); this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel));
this._registerTooltip('topicShape', "Topic shape"); this._registerTooltip('topicShape', "Topic shape");
}
var topicIconBtn = $('topicIcon');
if (topicIconBtn) {
// Create icon panel dialog ... // Create icon panel dialog ...
var topicIconModel = { var topicIconModel = {
getValue: function() { getValue: function() {
@ -117,11 +126,13 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.IconPanel('topicIcon', topicIconModel)); this._toolbarElems.push(new mindplot.widget.IconPanel('topicIcon', topicIconModel));
this._registerTooltip('topicIcon', "Icon"); this._registerTooltip('topicIcon', "Icon");
}
// Topic color item ... // Topic color item ...
var topicColorModel = var topicColorBtn = $('topicColor');
{ if (topicColorBtn) {
var topicColorModel = {
getValue : function() { getValue : function() {
var nodes = designerModel.filterSelectedTopics(); var nodes = designerModel.filterSelectedTopics();
var result = null; var result = null;
@ -141,9 +152,11 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl)); this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl));
this._registerTooltip('topicColor', "Topic color"); this._registerTooltip('topicColor', "Topic color");
}
// Border color item ... // Border color item ...
var topicBorderBtn = $('topicBorder');
if (topicBorderBtn) {
var borderColorModel = var borderColorModel =
{ {
getValue : function() { getValue : function() {
@ -165,9 +178,11 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl)); this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
this._registerTooltip('topicBorder', "Border color"); this._registerTooltip('topicBorder', "Border color");
}
// Font color item ... // Font color item ...
var fontColorBtn = $('fontColor');
if (fontColorBtn) {
var fontColorModel = var fontColorModel =
{ {
getValue : function() { getValue : function() {
@ -189,7 +204,7 @@ mindplot.widget.Menu = new Class({
}; };
this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl)); this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl));
this._registerTooltip('fontColor', "Text color"); 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,19 +2,19 @@
<div id="toolbar"> <div id="toolbar">
<div id="persist" class="buttonContainer"> <div id="persist" class="buttonContainer">
<c:if test="${!readOnlyMode}">
<div id="save" class="buttonOn"> <div id="save" class="buttonOn">
<img src="../images/save.png"/> <img src="../images/save.png"/>
</div> </div>
<div id="discard" class="buttonOn"> <div id="discard" class="buttonOn">
<img src="../images/discard.png"/> <img src="../images/discard.png"/>
</div> </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>
<c:if test="${!readOnlyMode}">
<div id="edit" class="buttonContainer"> <div id="edit" class="buttonContainer">
<div id="undoEdition" class="buttonOn"> <div id="undoEdition" class="buttonOn">
<img src="../images/undo.png"/> <img src="../images/undo.png"/>
@ -23,6 +23,7 @@
<img src="../images/redo.png"/> <img src="../images/redo.png"/>
</div> </div>
</div> </div>
</c:if>
<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,6 +32,7 @@
<img src="../images/zoom-out.png"/> <img src="../images/zoom-out.png"/>
</div> </div>
</div> </div>
<c:if test="${!readOnlyMode}">
<div id="node" class="buttonContainer"> <div id="node" class="buttonContainer">
<div id="topicShape" class="buttonExtOn"> <div id="topicShape" class="buttonExtOn">
<img src="../images/topic-shape.png"/> <img src="../images/topic-shape.png"/>
@ -77,9 +79,9 @@
<img src="../images/font-color.png"/> <img src="../images/font-color.png"/>
</div> </div>
</div> </div>
</c:if>
<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="export" class="buttonOn">
<img src="../images/export.png"/>
</div>
<c:if test="${!readOnlyMode}">
<div id="history" class="buttonOn"> <div id="history" class="buttonOn">
<img src="../images/history.png"/> <img src="../images/history.png"/>
</div> </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>