Order of the side bar items - seedstack

Is there a way to reorder entries of the side bar of a w20-business-theme based web application having its master page generated automatically (other than using categories).
Thank you!

To sort side bar's entries, we need to use the sortKey property.
Small example:
"routes": {
"home": {
"template": "<h1>Hello World!</h1>",
"hidden": true
},
"components1": {
"templateUrl": "{demo}/views/components.html",
"sortKey": 10
},
"components2": {
"templateUrl": "{demo}/views/components.html",
"sortKey": 30
},
"components3": {
"templateUrl": "{demo}/views/components.html",
"sortKey": 20
},
"components4": {
"templateUrl": "{demo}/views/components.html",
"sortKey": 50
}
}

Related

Creating a couchdb view to index if item in an array exists

I have the following sample documents in my couchdb. The original table in production has about 2M records.
{
{
"_id": "someid|goes|here",
"collected": {
"tags": ["abc", "def", "ghi"]
}
},
{
"_id": "someid1|goes|here",
"collected": {
"tags": ["abc", "klm","pqr"]
},
},
{
"_id": "someid2|goes|here",
"collected": {
"tags": ["efg", "hij","klm"]
},
}
}
Based on my previous question here, how to search for values when the selector is an array,
I currently have an index added for the collected.tags field, but the search is still taking a long time. Here is the search query I have.
{
"selector": {
"collected.tags": {
"$elemMatch": {
"$regex": "abc"
}
}
}
}
There are about 300k records matching the above condition, there search seems to take a long time. So, I want to create a indexed view to retrieve and lookup faster instead of a find/search. I am new to couchdb and am not sure how to setup the map function to create the indexed view.
Figured the map function out myself. Now all the documents are indexed and retrievals are faster
function (doc) {
if(doc.collected.tags.indexOf('abc') > -1){
emit(doc._id, doc);
}
}

Update Amcharts4 chart dynamically using vue js

I'm using AmCharts4 with Vue.JS,
For the moment I've added default chart design when page loads, But when I trying to add dynamic values after page loads (Using Button click), It doesn't reflect on view.
Code:- gist
data: () => ({
dataForChart: {
data: [{
"name": "Anne",
"steps": 32
}, {
"name": "Rose",
"steps": 30
}, {
"name": "Jane",
"steps": 25
}]
}
}),
chart creation on mounted()
let chart = am4core.create("chart-div", am4charts.XYChart);
chart.data = this.dataForChart.data
when dynamically change values using button click those data doesnt reflect on chart.
method followed to change data set.
this.dataForChart.data = {
data: [{
"name": "Anne",
"steps": 54
}, {
"name": "Rose",
"steps": 44
}, {
"name": "Jane",
"steps": 33
}]
}
The reason for this is that although this.dataForChart.data is reactive (it's a vue instance property) the chart.data (amcharts chart property) is not.
You have to manually set chart.data array values whenever your this.dataForChart.data property changes. I've done this by setting a watcher on this.dataForChart.data like so:
watch: {
dataForChart: {
data(values) {
this.chart.data = values;
},
deep: true
}
}
Cheers!

how to count number of keys in embedded mongodb document

I have a mongodb query: (Give me the settings where account='test')
db.collection_name.find({"account" : "test1"}, {settings : 1}).pretty();
where I get the following sample output:
{
"_id" : ObjectId("49830ede4bz08bc0b495f123"),
"settings" : {
"clusterData" : {
"us-south-1" : "cluster1",
"us-east-1" : "cluster2"
},
},
What I'm looking for now, is to give me the account where the clusterData has more than 1 key.
I'm only interested in listing those accounts with (2) or more keys.
I've tried this: (but this doesn't work)
db.collection_name.find({'settings.clusterData.1': {$exists: true}}, {account : 1}).pretty();
Is this possible to do with the current data structure? I don't have the option to redesign this schema.
Your clusterData field is not an array which is why you cannot just filter the number of elements it has. There is a way, though, to get what you want via the aggregation framework. Try this:
db.collection_name.aggregate({
$match: {
"account" : "test1"
}
}, {
$project: {
"settingsAsArraySize": { $size: { $objectToArray: "$settings.clusterData" } },
"settings.clusterData": 1
}
}, {
$match: {
"settingsAsArraySize": { $gt: 1 }
}
}, {
$project: {
"_id": 0,
"settings.clusterData": 1
}
}).pretty();

Draw not fired on fnAjaxReload / Ajax.Reload / __reload

I just have the curios issue that the draw event isn't allways fired when I reload my table.
Here is my table init:
mCommissionTable = $("#CommissionTable").dataTable({ "bJQueryUI": false, "sDom": 'lfrtip', "columns": [ { "data": "CommissionId" }, { "data": "Description" }, { "data": "CommissionTypeDisplayName" }, { "data": "DivisionCode" }, { "data": "EmployeeName" }, { "data": "EmployeeNumber" }, { "data": "PeriodFrom" }, { "data": "PeriodTill" }, { "data": "ApprovalStatusDisplayName" }, { "data": "StatusDisplayName" }, { "data": "Comment" } ] });
Here is my Refresh:
function onButtonClickA() { mCommissionTable.fnReloadAjax("GridCommunication.aspx?do=GetCommission" + mFilter, RefreshSelectedRows); }
Here is the RefreshSelectedRows:
function RefreshSelectedRows() { alert('fired!'); }
So everything works fine, table will not be loaded until I click the button the first time, everystime I click the button the table will be loaded. But in fact the callback (RefreshSelectedRows) is not fired every time.
In the DataTables.js code I found the __reload-method in which the API register the callback-event one time, Line 7140:
if (callback) {
var api = new _Api(settings);
api.one('draw', function () {
callback(api.ajax.json());
});
}
When I track it to that with Visual Studio and set breakpoint the Api,one-command will be hit with 100%, so it is registerred. The callback isself (what only happens when the event is fired) get hit randomly. I can't reproduce it. it just happened. I click 20 times on the button, 15 times it is okay, 5 times not...
I tried to track it down, but as far as I can see in the _fnReDraw method, where the fnDraw is called and the draw event in triggered everything is okay...
So... bug?
Any ideas?
Found the bug!
It was an old IE Version!
As soon as I started it with IE9+ it works like charm!

Adding an array element to all documents in a collection

My Foo documents have a CustomData collection used to add user-configurable properties.
Sometimes, when I create those properties, I'm need to add them with a default value for indexing purposes.
This is what I'm trying to use for that purpose:
DatabaseCommands.UpdateByIndex(
"dynamic/Foos",
new IndexQuery(),
new[]
{
new PatchRequest
{
Name = "CustomData",
Type = PatchCommandType.Add,
Value = RavenJObject.FromObject(new
{
Value = false,
Bar = new { Baz = "Qux"}
})
}
});
This generates the following HTTP request:
PATCH /databases/MyDb/bulk_docs/dynamic/Foos?&pageSize=128&allowStale=False
[
{
"Type": "Add",
"Value": {
"Value": false,
"Bar": {
"Baz": "Qux"
}
},
"Name": "CustomData"
}
]
And this returns 200 OK, but no documents are modified.
It looks like the problem is the usage of dynamic indexes.
Switching to a persistent index solved the problem.