예제 #1
0
  public String availableForBulkEdit(BulkEditBean bulkEditBean) {
    String rendererType = null;

    // Ensure that this field is not hidden in any Field Layouts the selected issues belong to
    for (FieldLayout fieldLayout : bulkEditBean.getFieldLayouts()) {
      if (fieldLayout.isFieldHidden(getId())) {
        return "bulk.edit.unavailable.hidden";
      }

      // Check for different renderer type
      if (StringUtils.isBlank(rendererType)) {
        rendererType = fieldLayout.getRendererTypeForField(IssueFieldConstants.COMMENT);
      } else if (!rendererType.equals(
          fieldLayout.getRendererTypeForField(IssueFieldConstants.COMMENT))) {
        return "bulk.edit.unavailable.different.renderers";
      }
    }

    // If we got here then the field is visible in all field layouts
    // So check for permissions
    // Have to loop through all the issues incase the permission has been granted to current
    // assignee/reporter (i.e. assigned to a role)
    for (Issue issue : bulkEditBean.getSelectedIssues()) {
      if (!isShown(issue)) {
        return "bulk.edit.unavailable.permission";
      }
    }

    // This field is available for bulk-editing, return null (i.e no unavailble message)
    return null;
  }
  public void testDoDefault() throws Exception {
    // Set Up a field with a description

    String testDescription = "test description";

    createFieldLayoutItem(testDescription);
    OrderableField orderableField =
        ComponentAccessor.getFieldManager().getOrderableField(IssueFieldConstants.ISSUE_TYPE);
    FieldLayout fieldLayout = null;
    if (getFieldLayoutId() != null)
      fieldLayout =
          ComponentAccessor.getFieldManager()
              .getFieldLayoutManager()
              .getFieldLayout(getFieldLayoutId());
    else fieldLayout = ComponentAccessor.getFieldManager().getFieldLayoutManager().getFieldLayout();

    List items = new ArrayList(fieldLayout.getFieldLayoutItems());
    Collections.sort(items);
    FieldLayoutItem fieldLayoutItem = fieldLayout.getFieldLayoutItem(orderableField);
    int position = items.indexOf(fieldLayoutItem);

    getEfli().setPosition(new Integer(position));

    String result = getEfli().doDefault();
    assertEquals(ActionSupport.INPUT, result);
    assertEquals(
        ComponentAccessor.getFieldManager().getField(IssueFieldConstants.ISSUE_TYPE).getName(),
        getEfli().getFieldName());
    assertEquals(testDescription, getEfli().getDescription());
  }
  private String getCommentHtml(Issue issue, Action action) {
    final OperationContext context = (OperationContext) action;

    final MapBuilder<String, Object> displayParams = MapBuilder.newBuilder();

    displayParams.add("theme", "aui");
    displayParams.add("noHeader", true);

    final FieldLayout fieldLayout = fieldLayoutManager.getFieldLayout(issue);
    final FieldLayoutItem commentFieldLayoutItem = fieldLayout.getFieldLayoutItem("comment");
    final OrderableField commentField = commentFieldLayoutItem.getOrderableField();

    return commentField.getCreateHtml(
        commentFieldLayoutItem, context, action, issue, displayParams.toMap());
  }