I'm experiencing little trouble getting Orionjs working within Angular-Meteor especially with the collections.
I had my old mongodb declarations, for instance :
Gallery = new Mongo.Collection('gallery') and so one.
As the documentation told , I wrote
Gallery = new orion.collection('gallery') but what I get is
Error: Match error: Expected object, got undefined
at exports.check (packages/check/match.js:34:1)
at new orion.collection (packages/orionjs:collections/new.js:8:3)
at meteorInstall.shared.collections.js (shared/collections.js:1:11)
So I tried to start a project from scratch with this framework.
Fact is, it doesn't work neither with Iron Router nor Flow Router.
Can anyone hit me with any hint about it?
Thank you guys.
Ideally OrionJS expect a schema detail like the label for singular and plural names, navigation detail, table layout for displaying data and so on.Here's a typical company collection shown below:
Company = new orion.collection('company', {
singularName: orion.helpers.getTranslation('company.singularName'),
pluralName: orion.helpers.getTranslation('company.pluralName'),
title: orion.helpers.getTranslation('company.title'),
link: {
title: orion.helpers.getTranslation('company.title'),
parent: 'collections-abc'
},
tabular: {
columns: [
{ data: '_id', title: orion.helpers.getTranslation('company.schema.id') },
{ data: 'name', title: orion.helpers.getTranslation('company.schema.name') }
]
}
});
You can also pass a null JSON if you do not wish to show page directly. Usually it expects a JSON like the one shown above.
Related
I am making a project with React and Typescript (SPFX) and I have created a webpart with about 4 components and each component has a different Content type id. At the moment, I need to make a query search every time I want to get the CT information in each component, like this:
const searchNews = async () => {
const searchQuery: ISearchQuery = {
Querytext: [
'ContentTypeId:0x010100C568DBD9B2FDCC96666E9F2007948130EC3DB054237AF39005CF914A33608B74B8D05F01*',
'ANFHighlightOWSBOOL=1'
].join(' '),
RowLimit: 10,
SelectProperties: [
'Title',
'Path',
'ANFHighlightOWSBOOL',
'ANFImageOWSIMGE',
'AuthorOWSUSER',
'CreatedOWSDate'
]
};
They have mostly all the same SelectProperties, with specific differences.
I saw we can do a query in the webpart property pane to have a CT dynamic return so we can access it in the component. I also saw this tutorial: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/dynamic-data But I am not quite sure how to make it and if there is a way to do it without de dynamic import.
How can I do a query in the property pane and make it usable in all my possible components?
I am using API's to receive multiple row data from a particular user, my doubt is how one can display that data in react using AG-Grid format.
this.setState
({
data: res.data,
columnDefs: [
{
headerName: " CreateDate", field: " CreateDate"
}, {
headerName: "Task Name", field: "TaskName"
}],
rowData:[{
//facing errors while assigning these values
TaskName : data.TaskName,
CreateDate : data[0].CreateDate
}]
})
Hi Aboli I am sharing stackblitz which will help you to do what you are trying to achieve.
I have assumed a lot about your data object since we dont know much about it. usually data should come in key value pair where keys matches to the field name which you have defined in your coldef object so that ag-grid can consume it directly.
But sometimes we need to sanitize data so that it matches with the way column field have been defined. feel free to ask more question and try to be a bit elaborative with code so that you can get solution faster.
here is the stackblitz example.
Hi I created a SimpleSchema for a Mongo collection which has a variable number of sub-documents called measurables. Unfortunately it's been a while since I've done this and I can't remember how to insert into this type of schema! Can someone help me out?
The schema is as follows:
const ExerciseTemplates = new Mongo.Collection('ExerciseTemplates');
const ExerciseTemplateSchema = new SimpleSchema({
name: {
type: String,
label: 'name',
},
description: {
type: String,
label: 'description',
},
createdAt: {
type: Date,
label: 'date',
},
measurables: {
type: Array,
minCount: 1,
},
'measurables.$': Object,
'measurables.$.name': String,
'measurables.$.unit': String,
});
ExerciseTemplates.attachSchema(ExerciseTemplateSchema);
The method is:
Meteor.methods({
addNewExerciseTemplate(name, description, measurables) {
ExerciseTemplates.insert({
name,
description,
createdAt: new Date(),
measurables,
});
},
});
The data sent by my form for measurables is an array of objects.
The SimpleSchema docs seem to be out of date. If I use the example they show with measurables: type: [Object] for an array of objects. I get an error that the the type can't be an array and I should set it to Array.
Any suggestions would be awesome!!
Many thanks in advance!
edit:
The measurable variable contains the following data:
[{name: weight, unit: kg}]
With the schema above I get no error at all, it is silent as if it was successful, but when I check the db via CLI I have no collections. Am I doing something really stupid? When I create a new meteor app, it creates a Mongo db for me I assume - I'm not forgetting to actually create a db or something dumb?
Turns out I was stupid. The schema I posted was correct and works exactly as intended. The problem was that I defined my schema and method in a file in my imports directory, outside both client and server directories. This methods file was imported into the file with the form that calls the method, and therefore available on the client, but not imported into the server.
I guess that the method was being called on the client as a stub so I saw the console.log firing, but the method was not being called on the server therefore not hitting the db.
Good lesson for me regarding the new recommended file structure. Always import server side code in server/main.js!!! :D
Thanks for your help, thought I was going to go mad!
I'm building a very small app where the user chooses a category, then a logo from said category and submits a form.
The document with the categories and logos is a JSON, and I have a bit of experience with CouchDB, but I get the feeling that such an app is a revision conflict magnet, as it'd be difficult to keep track of different users using at the same time and trying to update the document with the same revision ID.
I haven't been able to find some code or idea dealing with this issue.
Here's how my JSON looks like:
$scope.categories = [
{
name: 'DIY',
logos : [
{
url:'img/...1.png',
votes:0
},
{
url:'img/...2.png',
votes:0
}
]
},
{
name: 'Food',
logos : [
{
url:'img/...1.png',
votes:0
},
{
url:'img/...2.png',
votes:0
},
...
Any idea on how to deal with such an issue?
Here's a live test version of the app.
It would be useful to understand the design of your app. If I were designing this, I think I would generate a new CouchDb document when the form is submitted to record each vote. This would avoid updating any shared document and any risk of conflicts. Showing the results would then be a map/reduce query on the "vote" documents.
A grid has editable rows, connected to a store which has a proxy.
It uses the api e.g.
proxy: {
type: 'ajax',
api: {
create: 'dm/acct/new.php',
read: 'dm/acct/read.php',
update: 'dm/acct/update.php',
destroy: 'dm/acct/rm.php'
},
extraParams: {
sess: 2345
},
If I add extraParms to the store's proxy e.g. {abc:123} as shown above, when I come to edit a field on a grid, that detail is accompanied by the record at the server with the value defined. I can inspect it in the read.php.
However, for testing, I tried replacing abc with an application level var, e.g.
{abc:RPA.app.A_GLOBAL_VAR}
results in
Uncaught TypeError: Cannot read property 'A_GLOBAL_VAR' of undefined - this surprised me since the var is declared at the Application level and I thought would be scoped and available. This error causes the application to fail to run at all.
I have got it working but I don't like my approach because I think it is using the wrong event and I have not been able to spot a more suitable one.
On the grid' cell dblClick event I have:
var sto = Ext.getCmp('acc_grid').getStore();
var proxy= sto.getProxy();
proxy.setExtraParam('abc', somevar );
I definitely get the value of abc:somvar server-side - so does what I want. I just think it is bad design/wrong event and wondered if there is a better way of attaching the extra param to the record when the update on an editable grid? I have looked at other examples but not stumbled across one that I have been able to relate to.
Many thanks
Kevin
Listen to the CellEditor plugin edit event rather than the cell dblclick...
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.plugin.CellEditing
When you set your cell editing plugin...
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners:{
edit:function(){ doSomething }
}
})
],