Color property is not shown when using GET all tags/projects API. - asana

when we use this API https://app.asana.com/api/1.0/tags, the id and name of the tag is alone exposed... we get this response without colour property
{"data":[{"id":745415432,"name":"niceTag"},{"id":74273131186,"name":"halfBoil"}, {"id":745540236,"name":"DummyTag"}]}
To get the colour property of the tags, we need to individually make a GET request to https://app.asana.com/api/1.0/projects/project-id.
{"data":{"id":123456789,"created_at":"2013-08-15T01:17:32.791Z","modified_at":"2013-08-27T19:14:00.570Z","name":"newPro","notes":"","archived":false,"workspace":{"id":6687953,"name":"t"},"color":"light-yellow","followers":[{"id":987654321,"name":"xxxxx"}]}}
I might be unnecessarily using the server resource for getting colour properties of individual tags. Is there any other way to get the colours?

In most requests for a set of resources, we send what's called the "compact" form - for tags and projects, this includes only the ID and name. However, you can use the opt_fields parameter to request specific fields. For example, if you wanted to get all projects with name and color (ID is always sent), you could use: https://app.asana.com/api/1.0/projects\?opt_fields\=name,color
This works for any fields you need in a collection. For more information on opt_fields and other tricks (like using opt_expand to expand embedded resources) see the documentation on input/output options.

Related

How do I get the expand properties when using JIRA ''Get IDs of updated worklogs'' REST api?

Using JIRA, I get a list of IDs for worklogs updated by using this api.
/rest/api/2/worklog/updated
I can get the regular request to work, but there is a parameter called expand to display additional properties of the worklog and I can not get these properties to appear.
Things I have tried so far.
/rest/api/2/worklog/updated?expand=spentTime
/rest/api/2/worklog/updated?expand=authorName,comment
The example response in JIRA document (link mentioned above) has a field called properties. It may be used to contain expand properties.
But I don't know why my response doesn't have that field.
If what you're looking for is timeSpent, expanding properties is not the correct approach. You're going to get the relevant workLogIds returned by Get IDs of updated worklogs, then make a second REST call to Get worklogs. This call will give you timeSpent, and updateAuthor among others. However, it will not give you comments; you'll be needing a different call for that.

Possible to select a specific entity without knowing the key in OData?

I have a problem where I need to select a specific value from a specific entity from a entity set, however, I need to do it in a way without knowing the key.
This is the query I actually need:
odata/..../picklistLabels(locale='en_GB',optionId=10819)/label
However I need to program it in a way so it automatically selects the label without knowing the optionId. Is there a way to do this in OData?
From your question, I think that you want to perform a navigation but you don't have a key. Unfortunately, this exact functionality isn't available, however, you can perform an expand like this:
odata/..../picklistLabels?$filter=locale eq 'en_GB' and optionId=10819&$expand=label
This will get you the same information that the other call would do but in a slightly different format, you would have to find the first element in the array and then get the label property to get that information
As an aside, if you have the option to change the server (I'm guessing not due to the sapui5 tag but it might be useful for other users) you could change the key. If the locale and the optionId are enough to identify the object, then you could make these into a composite key. Here is a link for an example within the WebAPI OData source code: https://github.com/OData/ODataSamples/tree/master/WebApi/v4/ODataCompositeKeySample

Can Orbeon controls have multiple values?

I think the answer is no, but the question has been put to me so I'd like to confirm. My understanding is that any custom XBL control that I create for use in Form Builder can have one and only one value. Is this correct?
I have always assumed this because the control name is then used in the data instance as the name of the node which contains the the value.
This question comes from the desire to have reusable components with multiple values, for example, an Address control so that addresses can be recorded consistently and the same set of fields does not need to be added many times. Orbeon does have some support for this in the form of Section Templates but because the control names stay the same in each instance of a Section Template this does not work well with our design.
The best idea I've had is that a custom control which records multiple values could encode all the values into a single text string for example in JSON. Of course, this is not ideal.
Are there any other options?
It is possible for controls to have multiple values. When that happens the values are typically stored in nested elements. I.e. a control could bound to an element <address>, and could create nested elements <street>, <city>,<country>, etc to store the different parts of the address.
In practice, you can look at how this is done in the Image Annotation annotation control (see wpaint.xbl), which creates nested elements <image> and <annotation>, leveraging the xxbl:mirror="true" functionality.

SmartGWT LiveGrid unable to apply style to grid records programmatically

I am using SmartGWT 2.5, specifically a ListGrid backed by a RESTDataSource.
The Server integration is achieved by way of a servlet, and I only need to implement fetchData(). The data is a List<Map<String, Object>> populated on the server side, converted into JSON and sent in the DSResponse. The Live grid backed by the datasource triggers a server fetch programmatically by way of grid.fetchData().
Requirement:
I wish to set a record base style (or custom style) based on the value of one of the record's attributes, which I send over from the server.
In order to do this, I have tried a DataArrivedHandler, where I iterate over the available rows, get the ListGridRecord from the grid using the row number, and use gridRecord.set_baseStyle(String stylename) or gridRecord.setCustomStyle(String stylename) to try and apply a greyed out css for that record. After this, I call grid.markForRedraw(), however to no effect. The CSS does not get applied.
I must mention that I have used the same css to grey out rows on a normal listGrid (no dataSource) very successfully.
Questions:
Is my strategy the right one?
Is there an alternative method to apply a style to a record based on an attribute value.
Your strategy is correct and I have successfully achieved your required functionality in code of mine. Make sure you are correctly getting the record and that the test attribute is present in it. I suggest a JSON.encode(record.getJsObj()) to see what your record actually is filled with. No need for markForRedraw() explicit call, as after the DataArrivedEvent has fired the ListGrid will redraw its view. Post a small code snippet if you need more help. Also as suggested from the comment from Alain, highlights might be another good option to look at.

How can I modify the queryset in the change list view depending on a parameter I set in the URL

My problem is the following and it is related to the change list view of the admin interface.
I have a workorder model with several fields to caracterize the work order.
They are : type, nature, scheduling_type (and others).
When I see the list view, I would like to be able to change the filter (thus be able to create complex ones depending on the values of the different fields of the workorder model - the ones above and dates for example).
I have found post showing how to modify the default queryset (using managers for example) but I can't find a post that will use a value that is given in the url (ex. admin/workorder/planned_corrective). When the parameter planned_corrective is found, it must be used to select the appropriate queryset or manager and render the corresponding list.
As a add on, I want from that list to be able to use the standard admin options (like list filters, search ...) on that query.
Hope it is clear and thanks in advance for your help.
It sounds like you're after a RESTful interface.
You could accomplish much of this just by being clever with your urls.py - ie, defining admin/workoder/planned_corrective and every other possible parameter that could be encoded in the URL.
A lot of this can also be accomplished just by adding a get-absolute-url method to your models.
Or, you could the effort into using something like the django-rest-interface in your app.

Resources