r342 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions/project java/org/wikitty/web/jsptag webapp/WEB-INF webapp/WEB-INF/jsp
Author: meynier Date: 2013-06-17 18:12:18 +0200 (Mon, 17 Jun 2013) New Revision: 342 Url: http://chorem.org/projects/chorem/repository/revisions/342 Log: Modified WikittyInput tag to generate input from WikittyExtensions and slightly enhanced the project dashboard for the status modification form Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/wikitty.tld Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-14 14:03:04 UTC (rev 341) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-17 16:12:18 UTC (rev 342) @@ -1,5 +1,6 @@ package org.chorem.webmotion.actions.project; +import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -12,10 +13,15 @@ import org.chorem.entities.Quotation; import org.chorem.entities.Project; import org.chorem.entities.Task; +import org.nuiton.wikitty.entities.WikittyExtension; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; import org.nuiton.wikitty.query.WikittyQueryResult; - +/** + * + * @author meynier + * + */ public class DashboardProjectAction extends WebMotionController { /** to use log facility, just put in your code: log.info(\"...\"); */ @@ -27,11 +33,12 @@ WikittyQueryResult<Quotation> quotationResult = null; WikittyQueryResult<Task> taskResult = null; HashMap<Quotation, List<Task>> taskMap = new HashMap<Quotation, List<Task>>(); + HashMap<Quotation, WikittyExtension> extMap = new HashMap<Quotation, WikittyExtension>(); //Fetch the project form the name (if it has been requested) if(id != null) { WikittyQuery projectQuery = new WikittyQueryMaker() - .eq(Project.ELEMENT_FIELD_PROJECT_NAME, id) + .ideq(id) .end(); projectResult = client.findAllByQuery(Project.class, projectQuery); @@ -60,6 +67,7 @@ taskResult = client.findAllByQuery(Task.class, taskQuery); taskMap.put(quote, taskResult.getAll()); + extMap.put(quote, getNextExtension(client, quote)); } @@ -80,11 +88,37 @@ else { return renderView("dashboardSingleProject.jsp", "title", "Tableau de bord projet", "projects", projectResult.getAll(), - "quotations", quotationResult.getAll(), "taskMap", taskMap); + "quotations", quotationResult.getAll(), "taskMap", taskMap, "extMap", extMap); } } - public Render requestProject(ChoremClient client, String projectname) { - return projectFilter(client, projectname); + public Render requestProject(ChoremClient client, String project_id) { + return projectFilter(client, project_id); } + + + + private WikittyExtension getNextExtension(ChoremClient client,Quotation object) { + Collection<String> extensions = object.getExtensionNames(); + + + if(extensions.contains("Closed")) return null; + + + String[] exts = {"Quotation", "Draft", "Sent", "Rejected", "Accepted", "Started", + "Delivered", "RSV", "Warranty", "Closed"}; + + + //reverse loop + for(int i = exts.length-1; i>=0; i--) { + if(extensions.contains(exts[i])) { + WikittyExtension ret = client.restoreExtensionLastVersion(exts[i+1]); + System.out.println("EXTENSION : " + ret); + return ret; + } + + } + return null; + + } } Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2013-06-14 14:03:04 UTC (rev 341) +++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2013-06-17 16:12:18 UTC (rev 342) @@ -28,9 +28,11 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.wikitty.WikittyException; import org.nuiton.wikitty.WikittyUtil; import org.nuiton.wikitty.entities.FieldType; import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; import javax.servlet.ServletContext; import javax.servlet.jsp.JspException; @@ -56,174 +58,210 @@ */ public class WikittyInput extends SimpleTagSupport implements DynamicAttributes { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(WikittyInput.class); + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(WikittyInput.class); - protected Map<String, Object> dynamicAttribute = new HashMap<String, Object>(); + protected Map<String, Object> dynamicAttribute = new HashMap<String, Object>(); - protected String name=""; - protected Object defaultValue=""; + protected String name=""; + protected Object defaultValue=""; + protected boolean emptyField = false; + protected Wikitty wikitty; + protected WikittyExtension extension = null; + protected String fqfield=""; - protected Wikitty wikitty; - protected String fqfield=""; + public void setDynamicAttribute(String uri, String localName, Object value) throws JspException { + dynamicAttribute.put(localName, value); + } - public void setDynamicAttribute(String uri, String localName, Object value) throws JspException { - dynamicAttribute.put(localName, value); - } + public void setName(String name) { + this.name = name; + } - public void setName(String name) { - this.name = name; - } + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } + public void setWikitty(Wikitty wikitty) { + this.wikitty = wikitty; + } - public void setWikitty(Wikitty wikitty) { - this.wikitty = wikitty; - } + public void setExtension(WikittyExtension extension) { + this.extension = extension; + } - public void setFqfield(String fqfield) { - this.fqfield = fqfield; - } + public void setFqfield(String fqfield) { + this.fqfield = fqfield; + } - @Override - public void doTag() throws JspException, IOException { - // par defaut si pas de name on utilise celui du field - if (StringUtils.isBlank(name)) { - name = fqfield; - } + @Override + public void doTag() throws JspException, IOException { + // par defaut si pas de name on utilise celui du field + if (StringUtils.isBlank(name)) { + name = fqfield; + } - JspWriter output = getJspContext().getOut(); - PageContext pageContext = (PageContext)getJspContext(); - ServletContext servletContext = pageContext.getServletContext(); - String contextPath = servletContext.getContextPath(); + JspWriter output = getJspContext().getOut(); + PageContext pageContext = (PageContext)getJspContext(); + ServletContext servletContext = pageContext.getServletContext(); + String contextPath = servletContext.getContextPath(); - String extName = WikittyUtil.getExtensionNameFromFQFieldName(fqfield); - String fieldName = WikittyUtil.getFieldNameFromFQFieldName(fqfield); - FieldType field = wikitty.getFieldType(fqfield); + String extName = WikittyUtil.getExtensionNameFromFQFieldName(fqfield); + String fieldName = WikittyUtil.getFieldNameFromFQFieldName(fqfield); + FieldType field = null; + try { + System.out.println("JE TENTE DE RECUPERER LE TYPE"); + field = wikitty.getFieldType(fqfield); + System.out.println("LE TYPE EXISTE"); + } + catch(Exception e) { + System.out.println("LE TYPE N'EXISTE PAS"); + System.out.println("JE CATCH L'EXCEPTION"); + if(extension == null) { + System.out.println("extension EST NULL"); + throw new JspException(e); + } + else { + System.out.println("JE RECUPERE LE TYPE DEPUIS L'EXTENSION"); + field = extension.getFieldType(WikittyUtil.getFieldNameFromFQFieldName(fqfield)); + emptyField = true; + } + } + - String visible = field.getTagValue("visible"); - if ("false".equals(visible)) { - // on affiche rien pour ce champs - return; - } - if (field != null) { - switch(field.getType()) { - case BINARY: - inputBinary(output, contextPath, name, wikitty, field, extName, fieldName); - break; - case BOOLEAN: - inputBoolean(output, contextPath, name, wikitty, field, extName, fieldName); - break; - case DATE: - inputDate(output, contextPath, name, wikitty, field, extName, fieldName); - break; - case NUMERIC: - inputNumeric(output, contextPath, name, wikitty, field, extName, fieldName); - break; - case STRING: - if (field.hasAllowed()) { - inputSelectString(output, contextPath, name, wikitty, field, extName, fieldName); - } else if (field.isCollection()){ - inputCollectionString(output, contextPath, name, wikitty, field, extName, fieldName); - } else { - inputString(output, contextPath, name, wikitty, field, extName, fieldName); - } - break; - case WIKITTY: - if (field.isCollection()) { - inputCollectionWikitty(output, contextPath, name, wikitty, field, extName, fieldName); - } else { - inputWikitty(output, contextPath, name, wikitty, field, extName, fieldName); - } - break; - } - String help = field.getTagValue("help"); - if (StringUtils.isNotBlank(help)) { - /*{ <i class="icon-question-sign" title="<%=help%>"></i>}*/ - } - } else { - /*{<div class="alert alert-error"><%=wikitty.getWikittyId()%> doesn't have field '<%=fqfield%>'</div>}*/ - } - } + - protected String getDynamicAttribute() { - String result = ""; - for (Map.Entry<String, Object> e : dynamicAttribute.entrySet()) { - result += " " + e.getKey() + "=\"" + e.getValue() + "\""; - } - return result; - } + if (field != null) { + String visible = field.getTagValue("visible"); + if ("false".equals(visible)) { + // on affiche rien pour ce champs + return; + } + + switch(field.getType()) { + case BINARY: + inputBinary(output, contextPath, name, wikitty, field, extName, fieldName); + break; + case BOOLEAN: + inputBoolean(output, contextPath, name, wikitty, field, extName, fieldName); + break; + case DATE: + inputDate(output, contextPath, name, wikitty, field, extName, fieldName); + break; + case NUMERIC: + inputNumeric(output, contextPath, name, wikitty, field, extName, fieldName); + break; + case STRING: + if (field.hasAllowed()) { + inputSelectString(output, contextPath, name, wikitty, field, extName, fieldName); + } else if (field.isCollection()){ + inputCollectionString(output, contextPath, name, wikitty, field, extName, fieldName); + } else { + inputString(output, contextPath, name, wikitty, field, extName, fieldName); + } + break; + case WIKITTY: + if (field.isCollection()) { + inputCollectionWikitty(output, contextPath, name, wikitty, field, extName, fieldName); + } else { + inputWikitty(output, contextPath, name, wikitty, field, extName, fieldName); + } + break; + } + String help = field.getTagValue("help"); + if (StringUtils.isNotBlank(help)) { + /*{ <i class="icon-question-sign" title="<%=help%>"></i>}*/ + } + } else { + /*{<div class="alert alert-error"><%=wikitty.getWikittyId()%> doesn't have field '<%=fqfield%>'</div>}*/ + } + } + protected String getDynamicAttribute() { + String result = ""; + for (Map.Entry<String, Object> e : dynamicAttribute.entrySet()) { + result += " " + e.getKey() + "=\"" + e.getValue() + "\""; + } + return result; + } - protected void inputBinary(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - /*{<input type="file" name="<%=name%>" <%=getDynamicAttribute()%>/>}*/ - } - protected void inputBoolean(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - boolean value = wikitty.getFieldAsBoolean(extName, fieldName); - String checked=""; - if (value) { - checked=" checked"; - } - /*{<input type="checkbox" name="<%=name%>"<%=checked%><%=getDynamicAttribute()%>/>}*/ - } + protected void inputBinary(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + /*{<input type="file" name="<%=name%>" <%=getDynamicAttribute()%>/>}*/ + } - protected void inputDate(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - Date date = wikitty.getFieldAsDate(extName, fieldName); - String value = ""; - if ("month".equals(field.getTagValue("subtype"))) { - if (date != null) { - value = DateFormatUtils.format(date, "MM/yyyy"); - } - /*{<input class="monthpicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ - } else if ("time".equals(field.getTagValue("subtype"))) { - if (date != null) { - value = DateFormatUtils.format(date, "HH:mm"); - } - /*{<input class="timepicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ - } else if ("datetime".equals(field.getTagValue("subtype"))) { - if (date != null) { - value = DateFormatUtils.format(date, "dd/MM/yyyy HH:mm"); - } - /*{<input class="datetimepicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ - } else { - if (date != null) { - value = DateFormatUtils.format(date, "dd/MM/yyyy"); - } - /*{<input class="datepicker" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ - } - } + protected void inputBoolean(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + boolean value = false; + if(!emptyField) + value = wikitty.getFieldAsBoolean(extName, fieldName); + String checked=""; + if (value) { + checked=" checked"; + } + /*{<input type="checkbox" name="<%=name%>"<%=checked%><%=getDynamicAttribute()%>/>}*/ + } - protected void inputNumeric(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - BigDecimal value = wikitty.getFieldAsBigDecimal(extName, fieldName); - NumberFormat formatter = NumberFormat.getNumberInstance(); - String formattedValue = formatter.format(value); - /*{<input type="text" name="<%=name%>" value="<%=formattedValue%>"<%=getDynamicAttribute()%>/>}*/ - } + protected void inputDate(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + Date date = null; + if(!emptyField) + date = wikitty.getFieldAsDate(extName, fieldName); + String value = ""; + if ("month".equals(field.getTagValue("subtype"))) { + if (date != null) { + value = DateFormatUtils.format(date, "MM/yyyy"); + } + /*{<input class="monthpicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ + } else if ("time".equals(field.getTagValue("subtype"))) { + if (date != null) { + value = DateFormatUtils.format(date, "HH:mm"); + } + /*{<input class="timepicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ + } else if ("datetime".equals(field.getTagValue("subtype"))) { + if (date != null) { + value = DateFormatUtils.format(date, "dd/MM/yyyy HH:mm"); + } + /*{<input class="datetimepicker" type="text" name="<%=name%>" value="<%=value%>" <%=getDynamicAttribute()%>/>}*/ + } else { + if (date != null) { + value = DateFormatUtils.format(date, "dd/MM/yyyy"); + } + /*{<input class="datepicker" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ + } + } - protected void inputString(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; - String fieldValue = wikitty.getFieldAsString(extName, fieldName); - String value = fieldValue !=null ? fieldValue : ""; - if ("monoline".equalsIgnoreCase(field.getSubtype())) { - /*{<input id="text-<%=id%>" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ - if (field.hasChoiceQuery()) { - String url = contextPath + "/wikitty-json/searchField?q=" + field.getChoiceQuery(); -/*{ + protected void inputNumeric(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + BigDecimal value = new BigDecimal(0); + if(!emptyField) + value= wikitty.getFieldAsBigDecimal(extName, fieldName); + NumberFormat formatter = NumberFormat.getNumberInstance(); + String formattedValue = formatter.format(value); + /*{<input type="text" name="<%=name%>" value="<%=formattedValue%>"<%=getDynamicAttribute()%>/>}*/ + } + + protected void inputString(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; + + String fieldValue = ""; + if(!emptyField) + fieldValue = wikitty.getFieldAsString(extName, fieldName); + String value = fieldValue !=null ? fieldValue : ""; + if ("monoline".equalsIgnoreCase(field.getSubtype())) { + /*{<input id="text-<%=id%>" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ + if (field.hasChoiceQuery()) { + String url = contextPath + "/wikitty-json/searchField?q=" + field.getChoiceQuery(); + /*{ <script> $(function() { $( "#text-<%=id%>" ).autocomplete({ @@ -233,44 +271,48 @@ }); </script> }*/ - } - } else { - /*{<textarea name="<%=name%>"<%=getDynamicAttribute()%>><%=value%></textarea>}*/ - } - } + } + } else { + /*{<textarea name="<%=name%>"<%=getDynamicAttribute()%>><%=value%></textarea>}*/ + } + } - protected void inputSelectString(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; - String value = wikitty.getFieldAsString(extName, fieldName); - /*{<select id="text-<%=id%>" name="<%=name%>" <%=getDynamicAttribute()%> }*/ - if (field.isCollection()) { - /*{ multiple="multiple" }*/ - } - /*{ >}*/ - List<String> allowedValues = field.getAllowedAsList(); - for (String allowedValue : allowedValues) { - String selected = ""; - if (allowedValue.equals(value)) { - selected = "selected"; - } - /*{<option value="<%=allowedValue%>" <%=selected%>><%=allowedValue%></option>}*/ - } - /*{</select>}*/ - } + protected void inputSelectString(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; + String value = ""; + if(!emptyField) + value = wikitty.getFieldAsString(extName, fieldName); + /*{<select id="text-<%=id%>" name="<%=name%>" <%=getDynamicAttribute()%> }*/ + if (field.isCollection()) { + /*{ multiple="multiple" }*/ + } + /*{ >}*/ + List<String> allowedValues = field.getAllowedAsList(); + for (String allowedValue : allowedValues) { + String selected = ""; + if (allowedValue.equals(value)) { + selected = "selected"; + } + /*{<option value="<%=allowedValue%>" <%=selected%>><%=allowedValue%></option>}*/ + } + /*{</select>}*/ + } - protected void inputCollectionString(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; - List<String> value = wikitty.getFieldAsList(extName, fieldName, String.class); + protected void inputCollectionString(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; + List<String> value = null; + if(!emptyField) + value = wikitty.getFieldAsList(extName, fieldName, String.class); - if ("monoline".equalsIgnoreCase(field.getSubtype())) { - /*{<input id="text-<%=id%>" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ - if (field.hasChoiceQuery()) { - String url = contextPath + "/wikitty-json/searchField?q=" + field.getChoiceQuery(); -/*{ + if ("monoline".equalsIgnoreCase(field.getSubtype())) { + /*{<input id="text-<%=id%>" type="text" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/ + if (field.hasChoiceQuery()) { + String url = contextPath + "/wikitty-json/searchField?q=" + field.getChoiceQuery(); + /*{ <script> $(function() { $( "#text-<%=id%>" ).autocomplete({ @@ -280,38 +322,43 @@ }); </script> }*/ - } - } else { - /*{<textarea name="<%=name%>"<%=getDynamicAttribute()%>><%=value%></textarea>}*/ - } - } + } + } else { + /*{<textarea name="<%=name%>"<%=getDynamicAttribute()%>><%=value%></textarea>}*/ + } + } - protected void inputWikitty(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; - String value = wikitty.getFieldAsWikitty(extName, fieldName); - Wikitty wikittyValue = wikitty.getFieldAsWikitty(extName, fieldName, false); + protected void inputWikitty(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; + String value = ""; + if(!emptyField) + value = wikitty.getFieldAsWikitty(extName, fieldName); + + Wikitty wikittyValue = null; + if(!emptyField) + wikittyValue = wikitty.getFieldAsWikitty(extName, fieldName, false); - String wlabel = ""; - if (wikittyValue != null) { - wlabel = wikittyValue.toString(); - } + String wlabel = ""; + if (wikittyValue != null) { + wlabel = wikittyValue.toString(); + } - String wid = ""; - if (value != null) { - wid = value; - } + String wid = ""; + if (value != null) { + wid = value; + } - String url = ""; - if (field.hasAllowed()) { - url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); - } else if (field.hasAllowedQuery()) { - url = contextPath + "/wikitty-json/search?query=" + field.getAllowedQuery(); - } else { - url = contextPath + "/wikitty-json/search?query="; - } -/*{ + String url = ""; + if (field.hasAllowed()) { + url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); + } else if (field.hasAllowedQuery()) { + url = contextPath + "/wikitty-json/search?query=" + field.getAllowedQuery(); + } else { + url = contextPath + "/wikitty-json/search?query="; + } + /*{ <script> $(function() { $( "#text-<%=id%>" ).autocompleteByExtension({ @@ -330,52 +377,54 @@ <input type="text" id="text-<%=id%>" value="<%=wlabel%>"<%=getDynamicAttribute()%>/> <input type="hidden" id="hidden-<%=id%>" name="<%=name%>" value="<%=wid%>"/> }*/ - } + } - protected void inputCollectionWikitty(JspWriter output, String contextPath, String name, - Wikitty wikitty, FieldType field, String extName , String fieldName) - throws JspException, IOException { - String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; - List<Wikitty> values = wikitty.getFieldAsWikittyList(extName, fieldName, false); + protected void inputCollectionWikitty(JspWriter output, String contextPath, String name, + Wikitty wikitty, FieldType field, String extName , String fieldName) + throws JspException, IOException { + String id = wikitty.getWikittyId() + "-" + extName + "-" + fieldName; + List<Wikitty> values = null; + if(!emptyField) + values = wikitty.getFieldAsWikittyList(extName, fieldName, false); -// String url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); - String url = ""; - if (field.hasAllowed()) { - url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); - } else if (field.hasAllowedQuery()) { - url = contextPath + "/wikitty-json/search?query=" + field.getAllowedQuery(); - } else { - url = contextPath + "/wikitty-json/search?query="; - } + // String url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); + String url = ""; + if (field.hasAllowed()) { + url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed(); + } else if (field.hasAllowedQuery()) { + url = contextPath + "/wikitty-json/search?query=" + field.getAllowedQuery(); + } else { + url = contextPath + "/wikitty-json/search?query="; + } - String sep = ""; - String prePopulate = "["; - if (values != null) { - for (Wikitty w :values) { - if (w != null) { - prePopulate += String.format("%s{id:'%s', label:'%s'}", sep, - StringEscapeUtils.escapeEcmaScript(w.getWikittyId()), - StringEscapeUtils.escapeEcmaScript(w.toString())); - sep = ","; - } - } - } - prePopulate += "]"; -/*{ + String sep = ""; + String prePopulate = "["; + if (values != null) { + for (Wikitty w :values) { + if (w != null) { + prePopulate += String.format("%s{id:'%s', label:'%s'}", sep, + StringEscapeUtils.escapeEcmaScript(w.getWikittyId()), + StringEscapeUtils.escapeEcmaScript(w.toString())); + sep = ","; + } + } + } + prePopulate += "]"; + /*{ <script type="text/javascript"> $(document).ready(function () { $("#text-<%=id%>").tokenInput("<%=url%>", { prePopulate: <%=prePopulate%>, preventDuplicates: true, propertyToSearch: "label" - + }); }); </script> <input type="text" id="text-<%=id%>" name="<%=name%>"<%=getDynamicAttribute()%>/> }*/ - } + } } Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-14 14:03:04 UTC (rev 341) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-17 16:12:18 UTC (rev 342) @@ -28,9 +28,33 @@ <h1>${title}</h1> <form class="well form-inline" method="GET"> - Nom du projet : <input class="input-large" type="text" - name="projectname" value="${param.projectname}" - placeholder="project name" /> <input type="submit" class="btn" /> + + <div class="control-group"> + Project Name : + <div class="controls" style="display: inline"> + + <script> + $(function() { + $( "#project_text" ).autocompleteByExtension({ + source: "/chorem/wikitty-json/search?extension=Project", + minLength: 2, + select: function( event, ui ) { + $( "#project_text" ).val( ui.item.label ); + $( "#project_hidden" ).val( ui.item.id ); + + return false; + } + }); + }); + </script> + + <input type="text" id="project_text" name="project_name" + value="${param.project_name}" placeholder="project name" /> <input + type="hidden" id="project_hidden" name="project_id" value="" /> <input + type="submit" class="btn" /> + </div> + </div> + </form> <c:choose> <c:when test="${projects.size() >= 1}"> @@ -82,30 +106,61 @@ </table> - Début : ${q.beginDate}<br /> - Fin : <w:display wikitty="${q.wikitty}" fqfield="Interval.endDate" - label="" /> + + + + <p> + Début : ${q.beginDate}<br /> Fin : + <w:display wikitty="${q.wikitty}" fqfield="Interval.endDate" + label="" /> + </p> <p>Liste des tâches :</p> - <c:forEach items="${taskMap}" var="entry"> + <c:forEach items="${taskMap}" var="entry"> <c:if test="${entry.key.equals(q)}"> - <ul> - <c:forEach items="${entry.value}" var="task"> - <li>${task.name} : ${task.description}</li> - </c:forEach> + <ul> + <c:forEach items="${entry.value}" var="task"> + <li><a + href="<c:url value="/wikitty/view/${task.wikittyId}"/>">${task.name} + : ${task.description}</a></li> + </c:forEach> + </ul> </c:if> - </ul> + </c:forEach> + + <c:forEach items="${extMap}" var="entry"> + <c:if test="${entry.key.equals(q)}"> + <c:if test="${entry.value != null}"> + ${entry.value.fieldNames} + <c:forEach items="${entry.value.fieldNames}" var="field"> + ${field} + <div class="control-group"> + <label class="control-label">${fieldName}</label> + <div class="controls"> + <w:input wikitty="${q.wikitty}" + fqfield="${entry.value.name}.${field}" extension="${entry.value}" /> + </div> + </div> + </c:forEach> + <input type="button" value="Tranformer en ${entry.value.name}" /> + + </c:if> + </c:if> + + + + </c:forEach> </c:forEach> </c:when> <c:otherwise> <c:if - test="${param.projectname != null && param.projectname.length() != 0 }"> -Projet inexistant -</c:if> + test="${param.project_id != null && param.projectname.length() != 0 }"> + Projet inexistant + </c:if> </c:otherwise> Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/wikitty.tld =================================================================== (Binary files differ)
participants (1)
-
meynier@users.chorem.org