Aurelia-slickgrid case insensitive search odata api - aurelia

I am trying to search Names using column search bar in aurelia slickgrid. This works with backend odata api
d/Customers?$count=true&$filter=(IsActive%20eq%20true%20and%20contains(Name,%20%27So%27))
But when i try to search small cased letters, it does not respond anything.
d/Customers?$count=true&$filter=(IsActive%20eq%20true%20and%20contains(Name,%20%27so%27))
Is there something i can do from aurelia-slickgrid to fix this? I also tried using this but i think backend complains that it does not have substring in filter.
$filter=(substringof('fol', Name))
My column looks like
this.customerColumnDefinition =
[
{
id: "Name", name: "Name", field: "Name", sortable: true, type: FieldType.string, filterable: true, minWidth: 100,
onCellClick: (e: Event, args: OnEventArgs): void => { this.router.navigateToRoute("customer", { businessUnitId: args.dataContext.Id }); }
},

Related

How to show/hide fields in the admin UI depending on the value from another field with KeystoneJS Next?

I have a Category model set in schema.ts as follows:
Category: list({
fields: {
name: text(),
type: select({
options: [
{ label: "MultipleChoice", value: "MultipleChoice" },
{ label: "Range", value: "Range" },
],
defaultValue: "...",
isRequired: true,
isUnique: true,
ui: { displayMode: "segmented-control" },
}),
from: integer(),
to: integer(),
options: text()
},
})
And this renders these components in the admin UI:
I'd like to show from and to fields only when Range is selected (hiding options field) and the other way around when MultipleChoice is selected. Is there a way to achieve that with Keystone Next?
I also tried another approach splitting the category types in different models and then relate them somehow with the Category model, but I'm not sure how to do so. Something like:
CategoryRange: list({
ui: {
isHidden: true,
},
fields: {
from: integer(),
to: integer(),
},
}),
CategoryMultipleChoice: list({
ui: {
isHidden: true,
},
fields: {
options: text(),
},
})
Conditional fields were supported in Keystone 4. They haven't been brought forward to Keystone 6 (aka. "Next") yet but they're on the roadmap. I'd expect support for them to arrive in the next few months.
Right now, in Keystone 6, probably the best you could do would be to create a custom field type that collected the "type" and "from/to" fields together. This would let you define an interface in the Admin UI that implemented whatever presentation rules you liked.

Resolve reference in Block Content in Sanity.io

I have the Content Block in Sanity like so:
export default {
title: "Block Content",
name: "blockContent",
type: "array",
of: [
/// stuff here
{
title: "Book",
type: "reference",
to: [{ type: "book" }],
},
],
};
When making a query like
'*[_type == "post"]{...,body[]{..., asset->{..., "_key": _id}, markDefs[]{..., _type == "internaLink" => {"slug": #.reference->slug}}}';
I get the reference, but I want to return the full Document. I tried every method but the documentation only explain references outside Content Blocks and those methods aren't working.
This is what's returned from the Query:
_createdAt: '2020-12-07T14:43:34Z',
_id: '9d628aa6-aba7-4b53-aa9f-c6e97583baf9',
_rev: 'ZZ0GkIKCRvD0tdMQPywPfl',
_type: 'post',
_updatedAt: '2020-12-07T14:43:34Z',
body: [
{
_key: '4184df372bae',
_type: 'block',
children: [Array],
markDefs: [],
style: 'normal'
},
{
_key: '56bed8835a7d',
_ref: 'dc2eefee-2200-43e1-99c7-ea989dda16ba',
_type: 'reference'
}
],
title: 'Example'
Solved, I'm writing the solution here as I found nothing on the web.
Basically I tried anything randomly until I got the desired result.
The query is:
_type=="reference"=>^->
I had a similar situation where I had was grabbing a story object that had a body which was a blockContent, and I had just added a blog reference as a block option to the body.
I solved it by using this query:
const query = groq`*[_type == "story" && slug.current == $slug][0]{
title,
description,
body[]{
_type == 'blog' => #->,
_type != 'blog' => #,
}
}`
It loops through all the array items inside of the body and if a specific one is a blog, then it dereferences it by using ->, otherwise it outputs the already existing value.

Vue/Vuetify Data Table OData Support

I have some odata-enabled endpoints that I'm looking to wire up to data tables in vue and have them automatically support server-side sorting, filtering and paging. The grid in Telerik's Kendo UI supports odata to the point where you tell the component that the data source type is odata and it automatically "just works" (https://demos.telerik.com/kendo-ui/grid/remote-data-binding) because odata is a well-defined standard.
I'm wondering if there is support for odata in other common vue-specific UI frameworks like vuetify. I've looked at vuetify specifically and it does seem to support server-side operations, but it's not clear to me how much custom logic I'm going to need to write in order to use odata since I haven't been able to find any specific examples.
Here is the source from the example linked above that shows how clean it is to wire up declaritively without any additional boilerplate logic:
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "number" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 550,
filterable: true,
sortable: true,
pageable: true,
columns: [{
field:"OrderID",
filterable: false
},
"Freight",
{
field: "OrderDate",
title: "Order Date",
format: "{0:MM/dd/yyyy}"
}, {
field: "ShipName",
title: "Ship Name"
}, {
field: "ShipCity",
title: "Ship City"
}
]
});
});
Vuetify doesn't seem to support odata yet, so your best bet is probably to write a client-side js solution.
Probably using one of these libraries.
O.js seems to be rather simple.

Set Keystone List "noedit" based on field value?

I would like to make my Keystone List object editable only if the object is not published. Here's my reduced List definition:
var Campaign = new keystone.List('Campaign', {
nodelete: true,
track: {
createdAt: true,
},
});
Campaign.add({
...,
publish: {
type: Types.Boolean,
required: false,
initial: false,
dependsOn: {
publishedOn: '',
},
},
publishedOn: {
type: Types.Datetime,
label: 'Published On',
hidden: true,
},
});
Is it possible to set noedit only if publishedOn is not null? I'm trying to prevent the object from being modified after it's "published", and am coming up short on examples.
The noedit property for a list or field is part of the model definition, and not part of the definition of an individual item. There is no way to mark a single item as uneditable in the admin UI unless you want to apply it to the field or model as a whole.
If you are less worried about clarity, and more worried about ensuring it cannot be edited, you could try the following:
Campaign.schema.post('init', function () {
if (this.published) this.invalidate('Published items cannot be edited');
});
This will cause an error to be thrown if you attempt to save the item once it is published.
While you could use dependsOn: { published: { $exists: true } } to filter fields, this would hide the information.
Interestingly, I was able to make the publish field simply check itself:
Campaign.add({
...,
publish: {
type: Types.Boolean,
required: false,
initial: false,
dependsOn: {
publish: false,
},
},
...,
});
and now it only shows if publish is false, which works exactly as I hoped it would.

Paging and grouping in dynamic grid

I am using dynamic grid using this plugin.
I want to make paging in it,
I tried like,
Ext.define('....', {
extend: 'Ext.data.Store',
pageSize: 10,
proxy: {
type: 'rest',
url: me.url,
reader: {
type: 'dynamicReader',
totalProperty: 'totalCount'
}
}
});
me.bbar = Ext.create('Ext.PagingToolbar', {
store: me.store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
In DynamicGrid.js totalProperty is not working. Am I setting the property properly there?
Then I am also trying to make grouping in the same plugin.
I have a combobox with some fields and want to select grouping field from it dynamically. When I select a field in combo box, it sends that data to grid's groupField property.
I have that combo box value selected in controller like,
var groupData = Ext.ComponentQuery.query('#groupid')[0].getValue();
I am sending it to grid like,
Ext.define('Group', {
singleton: true,
param: groupData
});
I am getting that for grid property (in DynamicGrid.js) like,
groupField: [Group.param]
But this automatically selects first field for groupField property before even selecting anything in combo box and makes grouping, selecting other fields in combo box also doesn't work, it always has first field for grouping.
What is going wrong? Please help.
I did grouping successfully by adding the following code in listener,
me.store.group(Group.param);
Still having issues with totalProperty, can someone help me to make it work?
I think I am making a mistake, now actual JSON response is,
[{
"userId": 123,
"name": "Ed Spencer",
"email": "ed#sencha.com"
}]
So the code for getting data and manipulating works fine like,
readRecords: function(data) {
if (data.length > 0) {
var item = data[0];
var fields = new Array();
var columns = new Array();
var p;
for (p in item) {
if (p && p != undefined) {
fields.push({name: p, type: 'floatOrString'});
columns.push({text: p, dataIndex: p});
}
}
data.metaData = { fields: fields, columns: columns };
}
return this.callParent([data]);
}
But for sending other metaData properties, from the docs I should probably have the following JSON response,
{
"count": 1,
"ok": true,
"msg": "Users found",
"users": [{
"userId": 123,
"name": "Ed Spencer",
"email": "ed#sencha.com"
}],
"metaData": {
"root": "users",
"idProperty": 'userId',
"totalProperty": 'count',
"successProperty": 'ok',
"messageProperty": 'msg'
}
}
So how do I point root in the readReords function so that it knows data is in root?
Thereby I will have other metaData properties also passed.
Please help!