JIRA Gadget Multiselect field select all - jira

I've created a JIRA gadget that has a multiselect field which by default (isConfigured == "false") has no field selected. Is it possible to have the default, when the gadget is first added to the dashboard that multiselect items are selected?

You can do this. Apply these changes to your gadget.xml file:
...
<UserPref name="projectId" display_name="Project" datatype="select" default_value="My def value"/>
...
fields: [
{
userpref: "projectId",
label: "Project",
type: "select",
selected: this.getPref("projectId"),
options: projects
},
...
More code you can find here: JIRA - list projects in configuration and remember selection

Related

Use selected item id from selected_tag in rails

view:
<%= select_tag 'template_id', options_from_collection_for_select(#templates, "id", "title", #template.id), class: "form-control", id: "template_select" %>
$('#template_select').on('change', function() {
<% sections = Section.where(is_template: true, template_id: selected_template_id ) %>
});
How can I use the selected item id from the tag in my sql query's template_id?
TLDR - look in the DOM for value attribute and query it with JS
You could try finding HTML input tag (with a hidden attribute) in the DOM which in turn should contain value attribute and then simply query it with JavaScript.
If the input tag is not visible near the select tag, just look for a value attribute near/inside the select tag which should contain the selected template id.

Antd Using <Table> as Array Form Input

i currently building a react app with ant-design UI. I have a problem regarding form. So far, i already able to create and submit normal form. But as i tried to create a more complex form, i faced these problem:
I want to create a form with input like this:
code: string,
name: string,
order: {
itemid: number,
qty: number
}
the 'order' part is an array, which means i can have more than 1 order in one form. I want to create that part of the form by using component in antd, where i can render the column like this:
{ title: L('Item Id'), width: 150, render: (text: string, item: any, index: any) => (
<Form.Item {...formItemLayout}>
{getFieldDecorator('order[' + index + '].itemid', {
rules: [{
required: true, message: 'Please select id!'
}]
})(
<ItemIdSelectInput/>
)}
</Form.Item>
) }
Can i use the table like that?
Also, as far as i know, component must have a 'datasource' in order to be used, while i want to create a 'Create' form where has no initial value (empty). Is there any reference or a better way to create this kind of form in antd? Thanks in advance!

Web2py conditionally readable field

Complete newbie to web2py... I want to make the check box at the bottom of the form appear conditionally only if a user is an admin-user. How can I address the name of the field so that I can change if a a non admin user doesn't see it?
I'm using a for loop to have a looping variable to reference, not sure that i need it...
## create all tables needed by Technical Request Form
db.define_table('technical_request',
Field('uuid', 'string', default=uuid.uuid4(), readable=False, writable=False),
Field('firstname', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'), label="First Name"),
Field('lastname', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'), label="Last Name"),
Field('phone', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'), label="Phone Number"),
Field('email', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'), label="Email"),
Field('issue_name', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'),label="Subject"),
Field('about_issue', 'text', requires=IS_NOT_EMPTY(error_message='All Fields are Required!'), label="Description of issue "),
Field('issue', 'upload', label="Attach Files "),
Field('request_processed', 'boolean', default=False, readable = False),
auth.signature)
for field in db.technical_request:
if field.name == 'request_processed' and auth.has_group_membership("systemadmin"):
field.readable = True
This is the check box I want to hide ....
Follow up question *
Is there a way I can conditionally add the Field?
No need to loop -- you can just access the field directly via its name:
db.technical_request.request_processed.readable = auth.has_group_membership("systemadmin")
Or just do it when defining the field:
Field('request_processed', 'boolean', default=False,
readable=auth.has_group_membership("systemadmin"))

ui-grid how to get columns and headers to line up and span full width of the grid

I've just started testing with ui-grid to see if I can use it in some of my projects. The problem I am having is when it renders the columns are of various sizes and do not line up with the column headers.
Within my controller I am defining the gridOptions as follows:
var vm = this;
vm.smtGridOptions = {
columnDefs:
[{ field: 'smtTypeCodeText', displayName: 'Type' },
{ field: 'description', displayName: 'Description' },
{ field: 'location', displayName: 'Location' },
{ field: 'dateEntered', displayName: 'Date Entered' }
]
}
the data is bound further down using
vm.smtGridOptions.data = vm.detail.smts;
In my html I have the grid added as follows:
<div ng-show="name.detail.smts.length > 0" scroll-to-section>
[![enter image description here][1]][1]<hr style="clear: both; margin-bottom: 5px !important;"/>
<a class="anchorOffset" id="smts"></a>
<p>
<strong><em>SMTs</em></strong>
</p>
<div id="smtGrid" ui-grid="name.smtGridOptions" class="uigrid"></div>
</div>
As a note, I'm using ui-router in this project so name represents the ControllerAs for the current view.
Options and data binding are working but when the application renders. I get a grid rendered like this:
Is there a setting or CSS setting that will allow the grid columns to span (almost in a justified manner) the width of the grid. Currently it appears that it valuates the data in the grid and renders the column to match regardless of column definition.
Thanks in advance
I had the same problem. I'm using ui-router and ui-bootstrap. My grids were in a uib-tab element from the ui-bootstrap project. When switching between tabs I was experiencing the rendering you're seeing.
What worked for me was injecting 'ui.grid.autoResize' into my module and adding the ui-grid-auto-resize directive to my grid div.
On the the ui-grid tutorial page here: http://ui-grid.info/docs/#/tutorial/108_hidden_grids There is a link to this Plunker: http://plnkr.co/edit/fwdXMamTBrR1yKVwcohZ?p=preview which has a similar setup that I followed.
var app = angular.module('app', ['ui.grid', 'ui.bootstrap', 'ui.grid.autoResize']);
<div id="grid1" ui-grid="gridOptions" ui-grid-auto-resize class="grid"></div>

How do I display all selected options from multiselect listbox in edit view on Grails?

I am new to Grails development and have been having issues with <g:select> when it is used for a multi-select list. In my form, users can select between 1 to 6 options in a multi-select list box. They can then go back to an edit view to make changes.
The form successfully saves all the options that were selected, but if more than one option was selected, the listbox won't display that any were selected in the edit view. If only one option was selected however, it is displayed in the edit view correctly.
Could someone please give me some idea of how to fix it so that all selected options are displayed in edit view? (Running Grails 2.0.3)
Here is my <g:select> code in the GSP:
<g:select selected="true" multiple="true" name="securityGroup"
from="${['Mainframe', 'Finance', 'EDI', 'Item Master', 'Risk Management', 'Telecomm']}"
value="${MFAdminInstance?.securityGroup}"/>
Domain:
class MFAdmin {
static constraints = {
name(nullable:false, blank:false, unique:true)
briefDetail(nullable:false, blank:false)
details(blank:false)
recsz(nullable:false, blank:false)
securityGroup(nullable:false, blank:false)
files(nullable:false, blank:false)
begJCL(nullable:false, blank:false)
addJCL1(nullable:true, blank:true)
addJCL2(nullable:true, blank:true)
endJCL(nullable:false, blank:false)
}
String name
String briefDetail
String details
String recsz
String securityGroup
Integer files
String begJCL
String addJCL1
String addJCL2
String endJCL
}
Try being more explicit to the g:select tag that your value ${MFAdminInstance?.securityGroup} is a list. I'd suggest something like this:
${MFAdminInstance?.securityGroup?.toList()}
I was able to mock your code with something like:
<g:form action="update">
<g:select selected="true" multiple="true" name="securityGroup"
from="${['Mainframe', 'Finance', 'EDI', 'Item Master', 'Risk Management', 'Telecomm']}"
value="${bars}"/>
<g:submitButton name="submit" />
</g:form>
And within my action foo2 that handles the post:
def update() {
render(view: 'foo', model: [
bars: params.securityGroup.toList()
])
}
As you can see when I defined the list bars to be used in the gsp, I had to explicitly tell it that params.securityGroup is a list. Without that toList() at the end, the behavior was the missing selection for multiple select.
EDIT:
..inMFAdminInstance...
List<String> securityGroup
In your controller, you could store the selected post values to your domain with something like...
def mf = new MFAdminInstance()
mf.securityGroup = params.securityGroup?.toList()

Resources