I am working on a custom source plugin and I have 2 issues:
First, I want to create a field in the node my plugin creates, but i want the value of that field to be one of the config options
Something like this
{
resolve: 'plugin-name',
options: {
option1: 'value1'
},
},
createNodeField({
name: `field1`,
node,
value: configOption1,
})
Is that possible?
And also, whats the best way to do multiple calls of the same plugin? The API I am using forces me to do one request at a time for the data i need, no "overall" request.. is there a better way to do that instead of having {resolve: 'plugin-name', options: {option1} } x-times with different options in my gatsby-config.js?
Related
I'm using vue datatable, functionalities are working except callmethod() is not called on button click. When i click button no events are fired. Any Suggestions Please.
export default{
data(){
return{
columns: [
{label: 'name', field: 'name'},
{label: 'Link', representedAs: row => ` <button #click="callmethod(${row.id})"> </button>`, interpolate: true},
],
rows: [],
page: 1,
per_page: 10,
filter: '',
}
},
methods:{
callmethod()
{
console.log('function called');
},
EDIT: it looks like you're using vuejs-datatable actually. Still, there is only a presence of raw data and nothing like a callback there, so it should probably not be possible to do it there. Try to rather do it directly into your template somehow since nothing in the official documentation is talking about this.
Or maybe look another library that will allow you to do that. There are plenty and what you're trying to do may be easier with another package. The one you're currently using (vuejs-datatable) do only have 147 stars, so not the most popular. I'd recommend checking all the solutions available here: https://github.com/vuejs/awesome-vue#table
You can see the attached listeners like this, select the component from your vue devtools then check it's listeners in the console.
You're talking about Vuetify's v-data-table or another one? Because there is a lot of them around..
Also, from the official #data docs, we can see that it says
A rule of thumb is that data should just be data - it is not recommended to observe objects with their own stateful behavior.
You should not handle any kind of #click events into data so far. Are you sure your library is intended to work this way ?
I am running a query on more than one of my indexes (by using this and everything works fine. Now, I want to implement a faceted search using such functionality (this) but I am not being able to do it since I don't instantiate an index per each query I want to run. I tried to find some information out there about this but I was not able to find a solution for my problem and I want to avoid instantiating multiple indexes. Ideas?
This is a piece of the code I am using to search with multiple queries:
query.push({
indexName: 'My Index',
query: 'My Query', //I would like to use here something like 'NOT customAttr:"my value"'
params: {
hitsPerPage: 5
}
});
client.search(query, function searchDone(){});
Is there a way to configure a JsonRestStore to work with an existing web service that returns an array of objects which is not at the root-level of the JSON response?
My JSON response is currently similar to this:
{
message: "",
success: true,
data: [
{ name: "Bugs Bunny", id: 1 },
{ name: "Daffy Duck", id: 2 }
],
total: 2
}
I need to tell the JsonRestStore that it will find the rows under "data", but I can't see a way to do this from looking at the documentation. Schema seems like a possibility but I can't make sense of it through the docs (or what I find in Google).
My web services return data in a format expected by stores in Ext JS, but I can't refactor years worth of web services now (dealing with pagination via HTTP headers instead of query string values will probably be fun, too, but that's a problem for another day).
Thanks.
While it's only barely called out in the API docs, there is an internal method in dojox/data/JsonRestStore named _processResults that happens to be easily overridable for this purpose. It receives the data returned by the service and the original Deferred from the request, and is expected to return an object containing items and totalCount.
Based on your data above, something like this ought to work:
var CustomRestStore = declare(JsonRestStore, {
_processResults: function (results) {
return {
items: results.data,
totalCount: results.total
};
}
});
The idea with dojo/store is that reference stores are provided, but they are intended to be customized to match whatever data format you want. For example, https://github.com/sitepen/dojo-smore has a few additional stores (e.g. one that handles Csv data). These stores provide good examples for how to handle data that is offered under a different structure.
There's also the new dstore project, http://dstorejs.io/ , which is going to eventually replace dojo/store in Dojo 2, but works today against Dojo 1.x. This might be easier for creating a custom store to match your data structure.
I want to create paginated table using sails.js, mongodb and waterline-ORM.
Is there a any specific way to do pagination in sails.js?
http://sailsjs.org/#/documentation/concepts/ORM/Querylanguage.html
Model.find().paginate({page: 2, limit: 10});
Model.find({ where: { name: 'foo' }, limit: 10, skip: 10 });
If you want the pagination to work asynchronously, its very easy to do with JQUERY $$.getJSON and on the server res.json();
Theres a lot of info in waterline and sails docs.
There is also another way.
if you want to fetch data from the front-end, and have turned blueprint on, you can also try:
http://yourDomain.com/ModelName?skip=10&limit=10
Reference:
1.officer site: http://sailsjs.org/#/documentation/reference/blueprint-api/Find.html
You could build a functional paginator with built-in skip & limit query parameters for blueprint routes:
/api/todos?skip=10&limit=10
With this option, you could have dynamically sized page size according to various device sizes - this option you would provide with limit, which is basically your page size. Multiply (page size - 1) by current page number - voila you've got your skip parameter.
As to how to get the number of all items, I haven't found a built-in way to do it, so I've written a little helper middleware (https://github.com/xtrinch/sails-pagination-middleware) to return the total count in the response JSON this way:
{
"results": [
{
/* result here */
},
{
/* another result here */
}
],
"totalCount": 80
}
All you need to do is install the middleware via npm and add it to your middlewares in http.js.
If you need a fully functional example, I've also got an example to-do app with this sort of pagination on github: https://github.com/xtrinch/vue-sails-todo. It's written with vue, but you should get the idea either case.
Note that this answer requires sails 1.x.
I think you can also do it with io:
io.socket.get('/thing', {limit: 30, skip: 30*pageNum}, function(things, jwr) { /*...*/ })
So I have the source code for the Iteration Tracking Board on Rally. All I want to do is to add a query filter that is similar to the Portfolio Hierarchy app or the Portfolio Kanban Board.
If this is possible, I think that I may need to add it in the javascript code as a plugin and I was wondering how that should be coded.
Is this correct? Or can I not even add the filter as a plugin because it is not defined as one in Rally?
For some quick background, here is a guide on working with settings in apps: https://help.rallydev.com/apps/2.0rc2/doc/#!/guide/settings
This is a 2 parter. First, you'll need to add the query settings field to your app. Since this field is commonly used across apps there is a handy preconfigured on you can just reference by type:
getSettingsFields: function() {
var fields = this.callParent(arguments);
//...
//existing code omitted for brevity
//...
fields.push({type: 'query'});
return fields;
}
Then you'll need to actually use that setting to filter the data shown. Add the following to the cardBoardConfig object:
storeConfig: {
filters: this.getSetting('query') ?
[Rally.data.QueryFilter.fromQueryString(this.getSetting('query'))] : []
}