implemented tag system

This commit is contained in:
xseris 2017-11-24 20:19:49 +01:00
parent 4f67c632d0
commit a3132eeeb3
22 changed files with 1331 additions and 17 deletions

View File

@ -74,6 +74,7 @@ public abstract class ProjectManager {
protected Map<Long, ProjectMetadata> _projectsMetadata; protected Map<Long, ProjectMetadata> _projectsMetadata;
protected Map<String, Integer> _projectsTags;// TagName, number of projects having that tag
protected PreferenceStore _preferenceStore; protected PreferenceStore _preferenceStore;
final static Logger logger = LoggerFactory.getLogger("ProjectManager"); final static Logger logger = LoggerFactory.getLogger("ProjectManager");
@ -102,6 +103,7 @@ public abstract class ProjectManager {
_projectsMetadata = new HashMap<Long, ProjectMetadata>(); _projectsMetadata = new HashMap<Long, ProjectMetadata>();
_preferenceStore = new PreferenceStore(); _preferenceStore = new PreferenceStore();
_projects = new HashMap<Long, Project>(); _projects = new HashMap<Long, Project>();
_projectsTags = new HashMap<String, Integer>();
preparePreferenceStore(_preferenceStore); preparePreferenceStore(_preferenceStore);
} }
@ -128,6 +130,16 @@ public abstract class ProjectManager {
synchronized (this) { synchronized (this) {
_projects.put(project.id, project); _projects.put(project.id, project);
_projectsMetadata.put(project.id, projectMetadata); _projectsMetadata.put(project.id, projectMetadata);
if (_projectsTags == null)
_projectsTags = new HashMap<String, Integer>();
for (String tag : projectMetadata.getTags()) {
if (_projectsTags.containsKey(tag)) {
_projectsTags.put(tag, _projectsTags.get(tag) + 1);
} else {
_projectsTags.put(tag, 1);
}
}
} }
} }
@ -466,6 +478,15 @@ public abstract class ProjectManager {
return _projectsMetadata; return _projectsMetadata;
} }
/**
* Gets all the project tags currently held in memory
*
* @return
*/
public Map<String, Integer> getAllProjectTags() {
return _projectsTags;
}
/** /**
* Gets the required project from the data store * Gets the required project from the data store
* If project does not already exist in memory, it is loaded from the data store * If project does not already exist in memory, it is loaded from the data store

View File

@ -35,9 +35,11 @@ package com.google.refine;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -64,6 +66,8 @@ public class ProjectMetadata implements Jsonizable {
private String _encoding = ""; private String _encoding = "";
private int _encodingConfidence; private int _encodingConfidence;
private String[] _tags = new String[0];
private String _creator = ""; private String _creator = "";
private String _contributors = ""; private String _contributors = "";
private String _subject = ""; // Several refine projects may be linked private String _subject = ""; // Several refine projects may be linked
@ -119,6 +123,13 @@ public class ProjectMetadata implements Jsonizable {
} }
writer.endObject(); writer.endObject();
writer.key("tags");
writer.array();
for (String tag : _tags) {
writer.value(tag);
}
writer.endArray();
// write JSONArray directly // write JSONArray directly
if (_importOptionMetadata.length() > 0 ) { if (_importOptionMetadata.length() > 0 ) {
writer.key("importOptionMetadata"); writer.key("importOptionMetadata");
@ -196,6 +207,8 @@ public class ProjectMetadata implements Jsonizable {
pm._description = JSONUtilities.getString(obj, "description", ""); pm._description = JSONUtilities.getString(obj, "description", "");
pm._rowCount = JSONUtilities.getInt(obj, "rowCount", 0); pm._rowCount = JSONUtilities.getInt(obj, "rowCount", 0);
pm._tags = JSONUtilities.getStringArray(obj, "tags");
if (obj.has("preferences") && !obj.isNull("preferences")) { if (obj.has("preferences") && !obj.isNull("preferences")) {
try { try {
pm._preferenceStore.load(obj.getJSONObject("preferences")); pm._preferenceStore.load(obj.getJSONObject("preferences"));
@ -296,6 +309,32 @@ public class ProjectMetadata implements Jsonizable {
return _encodingConfidence; return _encodingConfidence;
} }
public void setTags(String[] tags) {
if (tags != null) {
List<String> tmpTags = new ArrayList<String>(tags.length);
for (String tag : tags) {
if (tag != null) {
String trimmedTag = tag.trim();
if (!trimmedTag.isEmpty()) {
tmpTags.add(trimmedTag);
}
}
}
this._tags = tmpTags.toArray(new String[tmpTags.size()]);
} else {
this._tags = tags;
}
updateModified();
}
public String[] getTags() {
if (_tags == null)
this._tags = new String[0];
return _tags;
}
public void setPassword(String password) { public void setPassword(String password) {
this._password = password; this._password = password;
updateModified(); updateModified();

View File

@ -34,22 +34,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.commands.project; package com.google.refine.commands.project;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.google.refine.ProjectManager; import com.google.refine.ProjectManager;
import com.google.refine.ProjectMetadata;
import com.google.refine.commands.Command; import com.google.refine.commands.Command;
public class DeleteProjectCommand extends Command { public class DeleteProjectCommand extends Command {
@Override @Override
public void doPost(HttpServletRequest request, HttpServletResponse response) public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
response.setHeader("Content-Type", "application/json");
try { try {
long projectID = Long.parseLong(request.getParameter("project")); long projectID = Long.parseLong(request.getParameter("project"));
// Remove the project tags from the general map
Map<String, Integer> allProjectTags = ProjectManager.singleton.getAllProjectTags();
ProjectMetadata metadata = ProjectManager.singleton.getProjectMetadata(projectID);
for (String tag : metadata.getTags()) {
if (allProjectTags.containsKey(tag)) {
int occurrence = allProjectTags.get(tag);
if (occurrence == 1)
allProjectTags.remove(tag);
else {
allProjectTags.put(tag, occurrence - 1);
}
}
}
ProjectManager.singleton.deleteProject(projectID); ProjectManager.singleton.deleteProject(projectID);
respond(response, "{ \"code\" : \"ok\" }"); respond(response, "{ \"code\" : \"ok\" }");

View File

@ -0,0 +1,106 @@
/*
*
* Copyright 2010, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package com.google.refine.commands.project;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import com.google.refine.ProjectManager;
import com.google.refine.ProjectMetadata;
import com.google.refine.commands.Command;
import com.google.refine.model.Project;
public class SetProjectTagsCommand extends Command {
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setHeader("Content-Type", "application/json");
try {
Project project;
try {
project = getProject(request);
} catch (ServletException e) {
respond(response, "error", e.getLocalizedMessage());
return;
}
ProjectMetadata metadata = project.getMetadata();
String oldT = request.getParameter("old");
String newT = request.getParameter("new");
Map<String, Integer> allProjectTags = ProjectManager.singleton.getAllProjectTags();
// Lets remove the old tags from the general map
String[] oldTags = oldT.split(",");
for (String tag : oldTags) {
if (allProjectTags!= null && allProjectTags.containsKey(tag)) {
int occurrence = allProjectTags.get(tag);
if (occurrence == 1) {
allProjectTags.remove(tag);
} else {
allProjectTags.put(tag, occurrence - 1);
}
}
}
// Lets add the new tags to the general map
String[] newTags = newT.split(" |\\,");
List<String> polishedTags = new ArrayList<String>(newTags.length);
for (String tag : newTags) {
tag = tag.trim();
if (!tag.isEmpty()) {
if (allProjectTags!= null && allProjectTags.containsKey(tag)) {
allProjectTags.put(tag, allProjectTags.get(tag) + 1);
} else {
allProjectTags.put(tag, 1);
}
polishedTags.add(tag);
}
}
// Lets update the project tags
metadata.setTags(polishedTags.toArray(new String[polishedTags.size()]));
metadata.updateModified();
respond(response, "{ \"code\" : \"ok\" }");
} catch (JSONException e) {
respondException(response, e);
}
}
}

View File

@ -0,0 +1,69 @@
/*
*
* Copyright 2010, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package com.google.refine.commands.workspace;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import org.json.JSONWriter;
import com.google.refine.ProjectManager;
import com.google.refine.commands.Command;
public class GetAllProjectTagsCommand extends Command {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
JSONWriter writer = new JSONWriter(response.getWriter());
// Properties options = new Properties();
writer.object();
writer.key("tags");
writer.array();
Map<String, Integer> tags = ProjectManager.singleton.getAllProjectTags();
if (tags != null) {
for (Map.Entry<String, Integer> entry : tags.entrySet()) {
writer.value(entry.getKey());
}
}
writer.endArray();
writer.endObject();
} catch (JSONException e) {
respondException(response, e);
}
}
}

View File

@ -1007,6 +1007,7 @@ public class ImportingUtilities {
) { ) {
ProjectMetadata pm = new ProjectMetadata(); ProjectMetadata pm = new ProjectMetadata();
pm.setName(JSONUtilities.getString(optionObj, "projectName", "Untitled")); pm.setName(JSONUtilities.getString(optionObj, "projectName", "Untitled"));
pm.setTags(JSONUtilities.getStringArray(optionObj, "projectTags"));
String encoding = JSONUtilities.getString(optionObj, "encoding", "UTF-8"); String encoding = JSONUtilities.getString(optionObj, "encoding", "UTF-8");
if ("".equals(encoding)) { if ("".equals(encoding)) {
// encoding can be present, but empty, which won't trigger JSONUtilities default processing // encoding can be present, but empty, which won't trigger JSONUtilities default processing

View File

@ -41,6 +41,7 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.HashMap;
import java.util.Properties; import java.util.Properties;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@ -119,8 +120,22 @@ public class FileProjectManager extends ProjectManager {
if (metadata == null) { if (metadata == null) {
metadata = ProjectMetadataUtilities.recover(getProjectDir(projectID), projectID); metadata = ProjectMetadataUtilities.recover(getProjectDir(projectID), projectID);
} }
if (metadata != null) { if (metadata != null) {
_projectsMetadata.put(projectID, metadata); _projectsMetadata.put(projectID, metadata);
if (_projectsTags == null) {
_projectsTags = new HashMap<String, Integer>();
}
if (metadata != null && metadata.getTags() != null) {
for (String tag : metadata.getTags()) {
if (_projectsTags.containsKey(tag)) {
_projectsTags.put(tag, _projectsTags.get(tag) + 1);
} else {
_projectsTags.put(tag, 1);
}
}
}
return true; return true;
} else { } else {
return false; return false;
@ -375,6 +390,16 @@ public class FileProjectManager extends ProjectManager {
mergeEmptyUserMetadata(metadata); mergeEmptyUserMetadata(metadata);
_projectsMetadata.put(id, metadata); _projectsMetadata.put(id, metadata);
if (metadata != null && metadata.getTags() != null) {
for (String tag : metadata.getTags()) {
if (_projectsTags.containsKey(tag)) {
_projectsTags.put(tag, _projectsTags.get(tag) + 1);
} else {
_projectsTags.put(tag, 1);
}
}
}
} }
if (obj.has("expressions") && !obj.isNull("expressions")) { // backward compatibility if (obj.has("expressions") && !obj.isNull("expressions")) { // backward compatibility

View File

@ -69,6 +69,8 @@ function registerCommands() {
RS.registerCommand(module, "get-project-metadata", new Packages.com.google.refine.commands.project.GetProjectMetadataCommand()); RS.registerCommand(module, "get-project-metadata", new Packages.com.google.refine.commands.project.GetProjectMetadataCommand());
RS.registerCommand(module, "get-all-project-metadata", new Packages.com.google.refine.commands.workspace.GetAllProjectMetadataCommand()); RS.registerCommand(module, "get-all-project-metadata", new Packages.com.google.refine.commands.workspace.GetAllProjectMetadataCommand());
RS.registerCommand(module, "set-metaData", new Packages.com.google.refine.commands.project.SetProjectMetadataCommand()); RS.registerCommand(module, "set-metaData", new Packages.com.google.refine.commands.project.SetProjectMetadataCommand());
RS.registerCommand(module, "get-all-project-tags", new Packages.com.google.refine.commands.workspace.GetAllProjectTagsCommand());
RS.registerCommand(module, "set-project-tags", new Packages.com.google.refine.commands.project.SetProjectTagsCommand());
RS.registerCommand(module, "delete-project", new Packages.com.google.refine.commands.project.DeleteProjectCommand()); RS.registerCommand(module, "delete-project", new Packages.com.google.refine.commands.project.DeleteProjectCommand());
RS.registerCommand(module, "delete-all-projects", new Packages.com.google.refine.commands.project.DeleteAllProjectsCommand()); RS.registerCommand(module, "delete-all-projects", new Packages.com.google.refine.commands.project.DeleteAllProjectsCommand());
@ -322,6 +324,8 @@ function init() {
"externals/jquery.i18n.js", "externals/jquery.i18n.js",
"externals/tablesorter/jquery.tablesorter.min.js", "externals/tablesorter/jquery.tablesorter.min.js",
"externals/moment-with-locales.min.js", "externals/moment-with-locales.min.js",
"externals/select2/select2.min.js",
"externals/jquery.lavalamp.min.js",
"scripts/util/misc.js", "scripts/util/misc.js",
"scripts/util/url.js", "scripts/util/url.js",
@ -333,6 +337,7 @@ function init() {
"scripts/util/date-time.js", "scripts/util/date-time.js",
"scripts/util/encoding.js", "scripts/util/encoding.js",
"scripts/util/sign.js", "scripts/util/sign.js",
"scripts/util/filter-lists.js",
"scripts/index.js", "scripts/index.js",
"scripts/index/create-project-ui.js", "scripts/index/create-project-ui.js",
@ -365,6 +370,7 @@ function init() {
module, module,
[ [
"externals/jquery-ui/css/ui-lightness/jquery-ui-1.10.3.custom.css", "externals/jquery-ui/css/ui-lightness/jquery-ui-1.10.3.custom.css",
"externals/select2/select2.css",
"externals/tablesorter/theme.blue.css", "externals/tablesorter/theme.blue.css",
"styles/jquery-ui-overrides.less", "styles/jquery-ui-overrides.less",
"styles/common.less", "styles/common.less",

View File

@ -0,0 +1,20 @@
/**
* Lava Lamp
* http://lavalamp.magicmediamuse.com/
*
* Author
* Richard Hung
* http://www.magicmediamuse.com/
*
* Version
* 1.0.6
*
* Copyright (c) 2014 Richard Hung.
*
* License
* Lava Lamp by Richard Hung is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
* http://creativecommons.org/licenses/by-nc/3.0/deed.en_US
*/
(function(e){var t={init:function(t){var i={easing:"swing",duration:700,margins:false,setOnClick:false,activeObj:".active",autoUpdate:false,updateTime:100,enableHover:true};var t=e.extend({},i,t);return this.each(function(){var i=t.easing;var s=t.duration;var o=t.margins;var u=t.setOnClick;var a=t.activeObj;var f=t.autoUpdate;var l=t.updateTime;var c=t.enableHover;var h=e(this);var p=h.children();var d=h.children(a);if(d.length==0){d=p.eq(0)}h.data({easing:i,duration:s,margins:o,setOnClick:u,active:d,enableHover:c,isAnim:false});h.addClass("lavalamp").css({position:"relative"});var v=e('<div class="lavalamp-object" />').prependTo(h).css({position:"absolute"});p.addClass("lavalamp-item").css({zIndex:5,position:"relative"});var m=d.outerWidth(o);var g=d.outerHeight(o);var y=d.position().top;var b=d.position().left;var w=d.css("marginTop");var E=d.css("marginLeft");if(!o){E=parseInt(E);w=parseInt(w);b=b+E;y=y+w}v.css({width:m,height:g,top:y,left:b});var S=false;n=function(){var t=e(this);S=true;h.lavalamp("anim",t)};r=function(){var e=h.data("active");S=false;h.lavalamp("anim",e)};if(c){h.on("mouseenter",".lavalamp-item",n);h.on("mouseleave",".lavalamp-item",r)}if(u){p.click(function(){d=e(this);h.data("active",d).lavalamp("update")})}if(f){setInterval(function(){var e=h.data("isAnim");if(S==false&&e==false){h.lavalamp("update")}},l)}})},destroy:function(){return this.each(function(){var t=e(this);var i=t.children(".lavalamp-item");var s=t.data("enableHover");if(s){t.off("mouseenter",".lavalamp-item",n);t.off("mouseleave",".lavalamp-item",r)}t.removeClass("lavalamp");i.removeClass("lavalamp-item");t.children(".lavalamp-object").remove();t.removeData()})},update:function(){return this.each(function(){var t=e(this);var n=t.children(":not(.lavalamp-object)");var r=t.data("active");var i=t.children(".lavalamp-object");n.addClass("lavalamp-item").css({zIndex:5,position:"relative"});t.lavalamp("anim",r)})},anim:function(e){var t=this;var n=t.data("duration");var r=t.data("easing");var i=t.data("margins");var s=t.children(".lavalamp-object");var o=e.outerWidth(i);var u=e.outerHeight(i);var a=e.position().top;var f=e.position().left;var l=e.css("marginTop");var c=e.css("marginLeft");if(!i){c=parseInt(c);l=parseInt(l);f=f+c;a=a+l}t.data("isAnim",true);s.stop(true,false).animate({width:o,height:u,top:a,left:f},n,r,function(){t.data("isAnim",false)})}};e.fn.lavalamp=function(n){if(t[n]){return t[n].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof n==="object"||!n){return t.init.apply(this,arguments)}else{e.error("Method "+n+" does not exist on jQuery.lavalamp")}};var n,r})(jQuery)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,704 @@
/*
Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
*/
.select2-container {
margin: 0;
position: relative;
display: inline-block;
/* inline-block for ie7 */
zoom: 1;
*display: inline;
vertical-align: middle;
}
.select2-container,
.select2-drop,
.select2-search,
.select2-search input {
/*
Force border-box so that % widths fit the parent
container without overlap because of margin/padding.
More Info : http://www.quirksmode.org/css/box.html
*/
-webkit-box-sizing: border-box; /* webkit */
-moz-box-sizing: border-box; /* firefox */
box-sizing: border-box; /* css3 */
}
.select2-container .select2-choice {
display: block;
height: 26px;
padding: 0 0 0 8px;
overflow: hidden;
position: relative;
border: 1px solid #aaa;
white-space: nowrap;
line-height: 26px;
color: #444;
text-decoration: none;
border-radius: 4px;
background-clip: padding-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #fff;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
background-image: linear-gradient(to top, #eee 0%, #fff 50%);
}
html[dir="rtl"] .select2-container .select2-choice {
padding: 0 8px 0 0;
}
.select2-container.select2-drop-above .select2-choice {
border-bottom-color: #aaa;
border-radius: 0 0 4px 4px;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
background-image: linear-gradient(to bottom, #eee 0%, #fff 90%);
}
.select2-container.select2-allowclear .select2-choice .select2-chosen {
margin-right: 42px;
}
.select2-container .select2-choice > .select2-chosen {
margin-right: 26px;
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
float: none;
width: auto;
}
html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
margin-left: 26px;
margin-right: 0;
}
.select2-container .select2-choice abbr {
display: none;
width: 12px;
height: 12px;
position: absolute;
right: 24px;
top: 8px;
font-size: 1px;
text-decoration: none;
border: 0;
background: url('select2.png') right top no-repeat;
cursor: pointer;
outline: 0;
}
.select2-container.select2-allowclear .select2-choice abbr {
display: inline-block;
}
.select2-container .select2-choice abbr:hover {
background-position: right -11px;
cursor: pointer;
}
.select2-drop-mask {
border: 0;
margin: 0;
padding: 0;
position: fixed;
left: 0;
top: 0;
min-height: 100%;
min-width: 100%;
height: auto;
width: auto;
opacity: 0;
z-index: 9998;
/* styles required for IE to work */
background-color: #fff;
filter: alpha(opacity=0);
}
.select2-drop {
width: 100%;
margin-top: -1px;
position: absolute;
z-index: 9999;
top: 100%;
background: #fff;
color: #000;
border: 1px solid #aaa;
border-top: 0;
border-radius: 0 0 4px 4px;
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
}
.select2-drop.select2-drop-above {
margin-top: 1px;
border-top: 1px solid #aaa;
border-bottom: 0;
border-radius: 4px 4px 0 0;
-webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
}
.select2-drop-active {
border: 1px solid #5897fb;
border-top: none;
}
.select2-drop.select2-drop-above.select2-drop-active {
border-top: 1px solid #5897fb;
}
.select2-drop-auto-width {
border-top: 1px solid #aaa;
width: auto;
}
.select2-drop-auto-width .select2-search {
padding-top: 4px;
}
.select2-container .select2-choice .select2-arrow {
display: inline-block;
width: 18px;
height: 100%;
position: absolute;
right: 0;
top: 0;
border-left: 1px solid #aaa;
border-radius: 0 4px 4px 0;
background-clip: padding-box;
background: #ccc;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
}
html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
left: 0;
right: auto;
border-left: none;
border-right: 1px solid #aaa;
border-radius: 4px 0 0 4px;
}
.select2-container .select2-choice .select2-arrow b {
display: block;
width: 100%;
height: 100%;
background: url('select2.png') no-repeat 0 1px;
}
html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
background-position: 2px 1px;
}
.select2-search {
display: inline-block;
width: 100%;
min-height: 26px;
margin: 0;
padding-left: 4px;
padding-right: 4px;
position: relative;
z-index: 10000;
white-space: nowrap;
}
.select2-search input {
width: 100%;
height: auto !important;
min-height: 26px;
padding: 4px 20px 4px 5px;
margin: 0;
outline: 0;
font-family: sans-serif;
font-size: 1em;
border: 1px solid #aaa;
border-radius: 0;
-webkit-box-shadow: none;
box-shadow: none;
background: #fff url('select2.png') no-repeat 100% -22px;
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
html[dir="rtl"] .select2-search input {
padding: 4px 5px 4px 20px;
background: #fff url('select2.png') no-repeat -37px -22px;
background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
.select2-drop.select2-drop-above .select2-search input {
margin-top: 4px;
}
.select2-search input.select2-active {
background: #fff url('select2-spinner.gif') no-repeat 100%;
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
.select2-container-active .select2-choice,
.select2-container-active .select2-choices {
border: 1px solid #5897fb;
outline: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.select2-dropdown-open .select2-choice {
border-bottom-color: transparent;
-webkit-box-shadow: 0 1px 0 #fff inset;
box-shadow: 0 1px 0 #fff inset;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
background-color: #eee;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
background-image: linear-gradient(to top, #fff 0%, #eee 50%);
}
.select2-dropdown-open.select2-drop-above .select2-choice,
.select2-dropdown-open.select2-drop-above .select2-choices {
border: 1px solid #5897fb;
border-top-color: transparent;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
background-image: linear-gradient(to bottom, #fff 0%, #eee 50%);
}
.select2-dropdown-open .select2-choice .select2-arrow {
background: transparent;
border-left: none;
filter: none;
}
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
border-right: none;
}
.select2-dropdown-open .select2-choice .select2-arrow b {
background-position: -18px 1px;
}
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
background-position: -16px 1px;
}
.select2-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/* results */
.select2-results {
max-height: 200px;
padding: 0 0 0 4px;
margin: 4px 4px 4px 0;
position: relative;
overflow-x: hidden;
overflow-y: auto;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html[dir="rtl"] .select2-results {
padding: 0 4px 0 0;
margin: 4px 0 4px 4px;
}
.select2-results ul.select2-result-sub {
margin: 0;
padding-left: 0;
}
.select2-results li {
list-style: none;
display: list-item;
background-image: none;
}
.select2-results li.select2-result-with-children > .select2-result-label {
font-weight: bold;
}
.select2-results .select2-result-label {
padding: 3px 7px 4px;
margin: 0;
cursor: pointer;
min-height: 1em;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.select2-results-dept-1 .select2-result-label { padding-left: 20px }
.select2-results-dept-2 .select2-result-label { padding-left: 40px }
.select2-results-dept-3 .select2-result-label { padding-left: 60px }
.select2-results-dept-4 .select2-result-label { padding-left: 80px }
.select2-results-dept-5 .select2-result-label { padding-left: 100px }
.select2-results-dept-6 .select2-result-label { padding-left: 110px }
.select2-results-dept-7 .select2-result-label { padding-left: 120px }
.select2-results .select2-highlighted {
background: #3875d7;
color: #fff;
}
.select2-results li em {
background: #feffde;
font-style: normal;
}
.select2-results .select2-highlighted em {
background: transparent;
}
.select2-results .select2-highlighted ul {
background: #fff;
color: #000;
}
.select2-results .select2-no-results,
.select2-results .select2-searching,
.select2-results .select2-ajax-error,
.select2-results .select2-selection-limit {
background: #f4f4f4;
display: list-item;
padding-left: 5px;
}
/*
disabled look for disabled choices in the results dropdown
*/
.select2-results .select2-disabled.select2-highlighted {
color: #666;
background: #f4f4f4;
display: list-item;
cursor: default;
}
.select2-results .select2-disabled {
background: #f4f4f4;
display: list-item;
cursor: default;
}
.select2-results .select2-selected {
display: none;
}
.select2-more-results.select2-active {
background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
}
.select2-results .select2-ajax-error {
background: rgba(255, 50, 50, .2);
}
.select2-more-results {
background: #f4f4f4;
display: list-item;
}
/* disabled styles */
.select2-container.select2-container-disabled .select2-choice {
background-color: #f4f4f4;
background-image: none;
border: 1px solid #ddd;
cursor: default;
}
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
background-color: #f4f4f4;
background-image: none;
border-left: 0;
}
.select2-container.select2-container-disabled .select2-choice abbr {
display: none;
}
/* multiselect */
.select2-container-multi .select2-choices {
height: auto !important;
height: 1%;
margin: 0;
padding: 0 5px 0 0;
position: relative;
border: 1px solid #aaa;
cursor: text;
overflow: hidden;
background-color: #fff;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
background-image: linear-gradient(to bottom, #eee 1%, #fff 15%);
}
html[dir="rtl"] .select2-container-multi .select2-choices {
padding: 0 0 0 5px;
}
.select2-locked {
padding: 3px 5px 3px 5px !important;
}
.select2-container-multi .select2-choices {
min-height: 26px;
}
.select2-container-multi.select2-container-active .select2-choices {
border: 1px solid #5897fb;
outline: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.select2-container-multi .select2-choices li {
float: left;
list-style: none;
}
html[dir="rtl"] .select2-container-multi .select2-choices li
{
float: right;
}
.select2-container-multi .select2-choices .select2-search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.select2-container-multi .select2-choices .select2-search-field input {
padding: 5px;
margin: 1px 0;
font-family: sans-serif;
font-size: 100%;
color: #666;
outline: 0;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
background: transparent !important;
}
.select2-container-multi .select2-choices .select2-search-field input.select2-active {
background: #fff url('select2-spinner.gif') no-repeat 100% !important;
}
.select2-default {
color: #999 !important;
}
.select2-container-multi .select2-choices .select2-search-choice {
padding: 3px 5px 3px 18px;
margin: 3px 0 3px 5px;
position: relative;
line-height: 13px;
color: #333;
cursor: default;
border: 1px solid #aaaaaa;
border-radius: 3px;
-webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
background-clip: padding-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #e4e4e4;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
}
html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
{
margin: 3px 5px 3px 0;
padding: 3px 18px 3px 5px;
}
.select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
cursor: default;
}
.select2-container-multi .select2-choices .select2-search-choice-focus {
background: #d4d4d4;
}
.select2-search-choice-close {
display: block;
width: 12px;
height: 13px;
position: absolute;
right: 3px;
top: 4px;
font-size: 1px;
outline: none;
background: url('select2.png') right top no-repeat;
}
html[dir="rtl"] .select2-search-choice-close {
right: auto;
left: 3px;
}
.select2-container-multi .select2-search-choice-close {
left: 3px;
}
html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
left: auto;
right: 2px;
}
.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
background-position: right -11px;
}
.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
background-position: right -11px;
}
/* disabled styles */
.select2-container-multi.select2-container-disabled .select2-choices {
background-color: #f4f4f4;
background-image: none;
border: 1px solid #ddd;
cursor: default;
}
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
padding: 3px 5px 3px 5px;
border: 1px solid #ddd;
background-image: none;
background-color: #f4f4f4;
}
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
background: none;
}
/* end multiselect */
.select2-result-selectable .select2-match,
.select2-result-unselectable .select2-match {
text-decoration: underline;
}
.select2-offscreen, .select2-offscreen:focus {
clip: rect(0 0 0 0) !important;
width: 1px !important;
height: 1px !important;
border: 0 !important;
margin: 0 !important;
padding: 0 !important;
overflow: hidden !important;
position: absolute !important;
outline: 0 !important;
left: 0px !important;
top: 0px !important;
}
.select2-display-none {
display: none;
}
.select2-measure-scrollbar {
position: absolute;
top: -10000px;
left: -10000px;
width: 100px;
height: 100px;
overflow: scroll;
}
/* Retina-ize icons */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
.select2-search input,
.select2-search-choice-close,
.select2-container .select2-choice abbr,
.select2-container .select2-choice .select2-arrow b {
background-image: url('select2x2.png') !important;
background-repeat: no-repeat !important;
background-size: 60px 40px !important;
}
.select2-search input {
background-position: 100% -21px !important;
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -72,6 +72,7 @@
"sel-by-regex": "Select by Regex on File Names", "sel-by-regex": "Select by Regex on File Names",
"parsing-options": "Configure Parsing Options", "parsing-options": "Configure Parsing Options",
"project-name": "Project&nbsp;name", "project-name": "Project&nbsp;name",
"project-tags": "Tags",
"updating-preview": "Updating preview ...", "updating-preview": "Updating preview ...",
"parse-as": "Parse data as", "parse-as": "Parse data as",
"this-computer": "This Computer", "this-computer": "This Computer",
@ -112,7 +113,10 @@
"warning-rename": "Failed to rename project:", "warning-rename": "Failed to rename project:",
"warning-proj-name": "You must specify a project name.", "warning-proj-name": "You must specify a project name.",
"warning-data-file": "You must specify a data file to upload or a URL to retrieve.", "warning-data-file": "You must specify a data file to upload or a URL to retrieve.",
"browse": "Browse workspace directory" "browse": "Browse workspace directory",
"tags": "Tags",
"edit-tags": "Edit project tags",
"edit-tags-desc": "Edit project tags (space and comma are delimiters):"
}, },
"core-index-lang": { "core-index-lang": {
"lang-settings": "Language Settings", "lang-settings": "Language Settings",

View File

@ -278,9 +278,12 @@ Refine.DefaultImportingController.prototype._createProject = function() {
return; return;
} }
var projectTags = $("#tagsInput").val().split(",");
var self = this; var self = this;
var options = this._formatParserUI.getOptions(); var options = this._formatParserUI.getOptions();
options.projectName = projectName; options.projectName = projectName;
options.projectTags = projectTags;
$.post( $.post(
"command/core/importing-controller?" + $.param({ "command/core/importing-controller?" + $.param({
"controller": "core/default-importing-controller", "controller": "core/default-importing-controller",
@ -333,3 +336,26 @@ Refine.DefaultImportingController.prototype._createProject = function() {
); );
} }
}; };
Refine.TagsManager = {};
Refine.TagsManager.allProjectTags = [];
Refine.TagsManager._getAllProjectTags = function() {
var self = this;
if (self.allProjectTags.length == 0) {
jQuery.ajax({
url : "command/core/get-all-project-tags",
success : function(result) {
var array = result.tags.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
for (var i = 0; i < array.length; i++) {
self.allProjectTags[i] = array[i];
}
},
async : false
});
}
return self.allProjectTags;
};

View File

@ -4,6 +4,12 @@
<td width="98%" id="or-import-parsopt"></td> <td width="98%" id="or-import-parsopt"></td>
<td style="text-align: right;" id="or-import-projname"></td> <td style="text-align: right;" id="or-import-projname"></td>
<td width="1%"><input class="inline" type="text" size="30" bind="projectNameInput" /></td> <td width="1%"><input class="inline" type="text" size="30" bind="projectNameInput" /></td>
<td style="text-align: right;" id="or-import-projtags"></td>
<td width="1%">
<div id="project-tags-container" class="inline">
<input type="hidden" id="tagsInput" style="width: 300px;" />
</div>
</td>
<td width="1%"><button bind="nextButton" class="button button-primary"></button></td> <td width="1%"><button bind="nextButton" class="button button-primary"></button></td>
</tr></table></div></div> </tr></table></div></div>

View File

@ -96,9 +96,16 @@ Refine.DefaultImportingController.prototype._prepareParsingPanel = function() {
this._parsingPanelElmts.nextButton.html($.i18n._('core-buttons')["create-project"]); this._parsingPanelElmts.nextButton.html($.i18n._('core-buttons')["create-project"]);
$('#or-import-parsopt').text($.i18n._('core-index-import')["parsing-options"]); $('#or-import-parsopt').text($.i18n._('core-index-import')["parsing-options"]);
$('#or-import-projname').html($.i18n._('core-index-import')["project-name"]); $('#or-import-projname').html($.i18n._('core-index-import')["project-name"]);
$('#or-import-projtags').html($.i18n._('core-index-import')["project-tags"]);
$('#or-import-updating').text($.i18n._('core-index-import')["updating-preview"]); $('#or-import-updating').text($.i18n._('core-index-import')["updating-preview"]);
$('#or-import-parseas').text($.i18n._('core-index-import')["parse-as"]); $('#or-import-parseas').text($.i18n._('core-index-import')["parse-as"]);
//tags dropdown
$("#tagsInput").select2({
tags: Refine.TagsManager._getAllProjectTags() ,
tokenSeparators: [",", " "]
});
this._parsingPanelResizer = function() { this._parsingPanelResizer = function() {
var elmts = self._parsingPanelElmts; var elmts = self._parsingPanelElmts;
var width = self._parsingPanel.width(); var width = self._parsingPanel.width();

View File

@ -1,4 +1,9 @@
<div class="relative-frame"> <div class="relative-frame">
<div bind="projectsContainer" id="projects-container"></div> <div bind="projectsContainer" id="projects-container">
<div bind="workspaceControls" id="projects-workspace-controls"><a id="projects-workspace-open" href="javascript:{}" class="secondary"></a></div> <div bind="projectTags" id="projectTags"></div>
<div bind="projectList" id="projects-list"></div>
</div>
<div bind="workspaceControls" id="projects-workspace-controls">
<a id="projects-workspace-open" href="javascript:{}" class="secondary"></a>
</div>
</div> </div>

View File

@ -70,8 +70,8 @@ Refine.OpenProjectUI = function(elmt) {
} }
}); });
}); });
Refine.TagsManager.allProjectTags = [];
this._fetchProjects(); this._buildTagsAndFetchProjects();
}; };
Refine.OpenProjectUI.prototype.resize = function() { Refine.OpenProjectUI.prototype.resize = function() {
@ -100,6 +100,53 @@ Refine.OpenProjectUI.prototype._fetchProjects = function() {
); );
}; };
Refine.OpenProjectUI.prototype._buildTagsAndFetchProjects = function() {
this._buildTagsListPanel();
this._fetchProjects();
};
Refine.OpenProjectUI.prototype._buildTagsListPanel = function() {
var self = this;
self._allTags = Refine.TagsManager._getAllProjectTags();
var container = self._elmts.projectTags.empty();
var ul = $("<ul/>").attr('id', 'tagsUl').appendTo(container);
// Add 'all' menu item
var li = $('<li/>').addClass("active").appendTo(ul);
$('<a/>').attr('href', '#all').addClass("current").text('All').appendTo(li);
$.each(self._allTags, function(i) {
var li = $('<li/>').appendTo(ul);
$('<a/>').attr('href', '#' + self._allTags[i]).text(self._allTags[i])
.appendTo(li);
});
self._addTagsListAnimation();
};
Refine.OpenProjectUI.prototype._addTagsListAnimation = function() {
$("#tagsUl").lavalamp({
setOnClick : true,
duration : 300
});
};
Refine.OpenProjectUI.prototype._fetchProjects = function() {
var self = this;
$.ajax({
type : 'GET',
url : "command/core/get-all-project-metadata",
dataType : 'json',
success : function(data) {
self._renderProjects(data);
self.resize();
},
data : {},
async : false
});
};
Refine.OpenProjectUI.prototype._renderProjects = function(data) { Refine.OpenProjectUI.prototype._renderProjects = function(data) {
var self = this; var self = this;
var projects = []; var projects = [];
@ -131,13 +178,13 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
projects.push(project); projects.push(project);
} }
var container = $("#projects-container").empty(); var container = self._elmts.projectList.empty();
if (!projects.length) { if (!projects.length) {
$("#no-project-message").clone().show().appendTo(container); $("#no-project-message").clone().show().appendTo(container);
} else { } else {
Refine.selectActionArea('open-project'); Refine.selectActionArea('open-project');
var projectsUl = $("<ul/>").attr('id', 'projectsUl').appendTo(container);
var table = $( var table = $(
'<table class="tablesorter-blue list-table"><thead><tr>' + '<table class="tablesorter-blue list-table"><thead><tr>' +
@ -149,6 +196,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
'<th>'+$.i18n._('core-index-open')["subject"]+'</th>' + '<th>'+$.i18n._('core-index-open')["subject"]+'</th>' +
'<th>'+$.i18n._('core-index-open')["description"]+'</th>' + '<th>'+$.i18n._('core-index-open')["description"]+'</th>' +
'<th>'+$.i18n._('core-index-open')["row-count"]+'</th>' + '<th>'+$.i18n._('core-index-open')["row-count"]+'</th>' +
'<th>'+$.i18n._('core-index-open')["tags"]+'</th>' +
(function() { (function() {
var htmlDisplay = ""; var htmlDisplay = "";
for (var n in data.customMetadataColumns) { for (var n in data.customMetadataColumns) {
@ -159,8 +207,8 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
return htmlDisplay; return htmlDisplay;
})() + })() +
'</tr></thead><tbody></tbody></table>' '</tr></thead><tbody id="tableBody"></tbody></table>'
).appendTo(container)[0]; ).appendTo(projectsUl)[0];
var allProjIds = ""; var allProjIds = "";
$.each(projects, function(i) { $.each(projects, function(i) {
@ -204,7 +252,8 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") { if (data && typeof data.code != 'undefined' && data.code == "ok") {
self._fetchProjects(); Refine.TagsManager.allProjectTags = [];
self._buildTagsAndFetchProjects();
} }
} }
}); });
@ -254,6 +303,61 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
appendMetaField(data[i].value); appendMetaField(data[i].value);
} }
} }
$(tr.insertCell(tr.cells.length));
var tags = project.tags;
for (var i = 0; i < tags.length; i++) {
var tag = tags[i];
$("<span/>")
.addClass("project-tag")
.text(tag)
.attr("title", $.i18n._('core-index-open')["edit-tags"])
.appendTo($(tr.cells[tr.cells.length - 1]));
$(tr).addClass(tag);
}
var editTagsLink = $('<a></a>')
.text($.i18n._('core-index-open')["rename"])
.addClass("secondary")
.addClass("edit-project-tags")
.css("visibility", "hidden")
.attr("href", "")
.attr("title", $.i18n._('core-index-open')["edit-tags"])
.html('<img src="images/edit.png" />')
.click(function() {
var oldTags = project.tags.join(",");
var newTags = window.prompt($.i18n._('core-index-open')["edit-tags-desc"],oldTags);
if (newTags === null || newTags == oldTags) {
return false;
}
$.ajax({
type : "POST",
url : "command/core/set-project-tags",
data : {
"project" : project.id,
"old" : oldTags,
"new" : newTags
},
dataType : "json",
success : function(data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") {
Refine.TagsManager.allProjectTags = [];
self._buildTagsAndFetchProjects();
} else {
alert($.i18n._('core-index-open')["warning-tags-update"]+ " "+ data.message);
}
}
});
return false;
}).appendTo($(tr.cells[tr.cells.length - 1]));
$(tr).mouseenter(function() {
editTagsLink.css("visibility", "visible");
}).mouseleave(function() {
editTagsLink.css("visibility", "hidden");
});
}; };
for (var i = 0; i < projects.length; i++) { for (var i = 0; i < projects.length; i++) {
@ -269,9 +373,14 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
sortList: [[2,1]], sortList: [[2,1]],
widthFixed: false widthFixed: false
}); });
self._addTagFilter();
} }
}; };
Refine.OpenProjectUI.prototype._addTagFilter = function() {
$("#tableBody").filterList();
};
Refine.OpenProjectUI.prototype._onClickUploadFileButton = function(evt) { Refine.OpenProjectUI.prototype._onClickUploadFileButton = function(evt) {
var projectName = $("#project-name-input")[0].value; var projectName = $("#project-name-input")[0].value;
var dataURL = $.trim($("#project-url-input")[0].value); var dataURL = $.trim($("#project-url-input")[0].value);

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2009 Joel Sutherland.
* Liscenced under the MIT liscense
*/
(function($) {
$.fn.filterList = function(settings) {
settings = $.extend(
{
animationSpeed: 500,
show: { height: 'show', opacity: 'show' },
hide: { height: 'hide', opacity: 'hide' },
useTags: true,
tagSelector: '#projectTags a',
selectedTagClass: 'current',
allTag: 'all'
}, settings);
var listElement = $(this);
/* FILTER: select a tag and filter */
listElement.bind("filter", function( e, tagToShow ){
if(settings.useTags){
$(settings.tagSelector).removeClass(settings.selectedTagClass);
$(settings.tagSelector + '[href=' + tagToShow + ']').addClass(settings.selectedTagClass);
}
$(this).trigger("filterMyList", [ tagToShow.substr(1) ]);
});
/* FILTERPORTFOLIO: pass in a class to show, all others will be hidden */
listElement.bind("filterMyList", function( e, classToShow ){
if(classToShow == settings.allTag){
$(this).trigger("show");
}else{
$(this).trigger("show", [ '.' + classToShow ] );
$(this).trigger("hide", [ ':not(.' + classToShow + ')' ] );
}
});
/* SHOW: show a single class*/
$(this).bind("show", function( e, selectorToShow ){
listElement.children(selectorToShow).animate(settings.show, settings.animationSpeed);
});
/* SHOW: hide a single class*/
$(this).bind("hide", function( e, selectorToHide ){
listElement.children(selectorToHide).animate(settings.hide, settings.animationSpeed * 0.6);
});
/* ============ Setup Tags ====================*/
if(settings.useTags){
$(settings.tagSelector).on("click", function(){
listElement.trigger("filter", [ $(this).attr('href') ]);
$(settings.tagSelector).removeClass('current');
$(this).addClass('current');
});
}
return this;
};
})(jQuery);

View File

@ -139,3 +139,71 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#metadata-body > table > tbody > tr:nth-child(1) > th:nth-child(3) { #metadata-body > table > tbody > tr:nth-child(1) > th:nth-child(3) {
width: 4% width: 4%
} }
/* Project Tags */
#projectTags {
position: relative;
padding: 3px 10px;
margin: 5px;
font-size: 130%;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #bcf;
min-height: 18px;
height: auto;
overflow:auto;
}
ul#tagsUl {
margin: 0;
padding: 0;
}
ul#tagsUl li {
list-style: none;
float: left;
text-align: center;
min-width: 80px;
}
ul#tagsUl li a {
padding: 6px 5px;
display : inline-block;
text-align: center;
color: #444;
text-shadow: 0 -1px 2px rgba(255, 255, 255, 0.60);
cursor: pointer;
font-weight: bold;
min-width: 50px;
}
ul#tagsUl li a {
text-decoration: none;
}
#projectTags .lavalamp-object {
background-color: #DEE6FF;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
/* Project List */
#projects-list{
overflow: auto;
}
.project .project-tag {
float: right;
padding: 3px 8px;
margin: 0px 2px;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
font-size: 100%;
font-weight: bold;
background: #28458A;
color: white;
cursor: pointer;
}