EDIT: I have figured out that I was trying to update by using appItemId (local for the app) in the ItemId field (global). The question now is how to update without using the global ItemId.
I have setup a script to authenticate as an app.
I can script fetching and creating new items no problem, but I can't edit or delete existing items. From the error message I can gather that the app does not have permissions to modify its own items.
How do I add those permissions?
So, this works:
var item = new Item();
item.Field<TextItemField>("title").Value = "blah";
podio.ItemService.AddNewItem(appId,item);
This doesn't:
var item = new Item { ItemId = 1 };
item.Field<TextItemField>("title").Value = "blah";
podio.ItemService.UpdateItem(item);
I found a way to do it by first fetching the item by appItemId and then updating it.
var item = podio.ItemService.GetItemByAppItemId(appId, appItemId);
item.Field<TextItemField>("title").Value = "ayyyy";
podio.ItemService.UpdateItem(item);
This works, although requires an additional GET request.
EDIT: The code before might not even work in all cases. So I had to do:
var item = new Item { ItemId = podio.ItemService.GetItemByAppItemId(appId, appItemId).ItemId};
item.Field<TextItemField>("myval").Value = "test";
podio.ItemService.UpdateItem(item, null, null, true);
because something breaks when updating with all the other values.
Related
Here is my reference. Everytime this function is called it in my firebase database it creates a new set of data under a unique token [Like this]: https://i.stack.imgur.com/ZPjEz.png. And i want to get that token.
let ref = firebase.database().ref('Products')
let newProduct = ref.push(newProduct)
newProduct.set({
color: color,
time: Date.now(),
})
Yes! I saw some similar questions like this but none of them couldn't help me.
Some please helps
I think this is what you need: https://firebase.google.com/docs/database/admin/save-data#getting-the-unique-key-generated-by-push
// Generate a reference to a new location and add some data using push()
var newPostRef = postsRef.push();
// Get the unique key generated by push()
var postId = newPostRef.key;
In your current code newProduct.key should already be set correctly, I think.
I am trying to paginate my table.
I have the full implementation of Angular Material Table with Pagination(https://material.angular.io/components/table/overview#pagination)
Since I am using Angularfire2 my dataSource is an Observable.
this.items = this.itemsCollection.valueChanges();
I read that I have to use
dataSource = new MatTableDataSource<Item>;
to create a working connection between table and paginator.
I populate the dataSource by
let subscription = this.items.subscribe(
newData => { this.dataSource.data = newData });
and update the dataSource's paginator by
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
}
where this.paginator is defined by
#ViewChild(MatPaginator) paginator: MatPaginator
like explained in Angular Material's components doc.
The paginator(mat-paginator) is working fine. However, my issue is that the table does not refresh and continues to show all values. Initial values to 'this.paginator' are also not passed to the table limit.
I found a known bug, but I am not sure if that applies to my problem...
Can anyone help me out?
Thank you in advanced!!
Update
I found an easy solution for my problem by using the Angular Pipe at mat-table. I added the slice pipe like this:
<mat-table #table [dataSource]="dataObservable | async | slice: a:b">
and in my data component I was listening to the change event of the HTML Element "mat-paginator"
(page)="changePage($event)"
In my component I can easily set the sliced data
a = 0;
b = this.limit;
changePage(ev) {
console.log( ev );
this.a = ev.pageIndex * ev.pageSize;
this.b = this.a + ev.pageSize;
console.log(this.a);
console.log(this.b);
}
I have created a module Products and content type product. I am creating a custom widget to display a single product. I have setup my designer and once I drop the widget on a page I can select from the product list using the sf-list-selector sf-dynamic-items-selector. My issue is matching the selected item ID to the list of products my widget is pulling up. Here is the code the widget uses to retrieve all products:
var dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
var contentType = TypeResolutionService.ResolveType(typeName);
var contentElements = dynamicModuleManager.GetDataItems(contentType).Where(x => x.Status == ContentLifecycleStatus.Live);
products = contentElements.ToArray().Select(p => new ItemViewModel(p)).ToArray();
This works good and pulls up the list of products. The question is how to filter this list using the selected product id from the designer. I have this and they don't match:
products.Single(p => p.DataItem.Id == Guid.Parse(selectedProductId))
How do I go from the ItemViewModel to the Id the selector is giving me?
using Feather 9.1
Went a different route. Instead of getting a list and filtering did so:
var dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
var contentType = TypeResolutionService.ResolveType(typeName);
var contentElement = dynamicModuleManager.GetDataItem(contentType, Guid.Parse(selectedProductId));
product = new ItemViewModel(dynamicModuleManager.Lifecycle.GetLive(contentElement));
I had a List that used to work when it was bound directly to a store but now I want that list to get it's data from a queryBy on the original store.
Looking at the documentation is seems like setItems should do what I want.
var myStore = Ext.getStore('myStoreData');
var myData = myStore.queryBy(function(item) {
return item.get('status') !== null;
});
// At this point myData looks valid and has the data I want.
// Ext.apply.create.Class {all: Array[5], items: Array[5], keys: Array[5], indices: Object, map: Object…}
Ext.getCmp('myListComponent').setItems(myData.items);
I keep getting the error "Object [object Object] has no method 'getItemId'". I tried various other incantations but without success. I also took a look at setData and add but without success.
========================
After getting Thiem's answer I just ended up creating a function that would create a filtered copy of an existing store and then just setting the List store to that. Code below for others edification...
storeCopy: function(store, filterBy) {
var records = [];
var allRecords = null;
if(filterBy)
allRecords= store.queryBy(filterBy);
else
allRecords= store.queryBy(function(){return true;});
allRecords.each(function(r){
var rec = r.copy();
rec.setId(r.getId());
records.push(rec);
});
var store2 = new Ext.data.Store({
recordType: store.recordType
});
store2.add(records);
return store2;
},
Thanks all.
setItems method does a totally different thing. For example, says you have an Ext.Container which consists of a form, some fields, and some interaction buttons. These things are call child components, or items of the container. They are oftenly declared in the items config of the parent container and setItems is designed to programmatically set the value of that config. So it has nothing to do with the store logic.
In your situation, here is one of the solutions:
Create a store instance which contains filtered data.
Use this command: yourList.setStore('yourFilteredStore')
And it should reload... hope this helps
I'm using mvc approach and extending the pandora example.
I would like to add a new record to a form. I need to pre-assign some properties. I have the following handler. Which fills out the form. However when i try and sync it does not post the new info. ie using fire bug i see that it post the records that were previously there. At what stage should i add it to the store.
onNewPartSelect: function (selModel, selection) {
var form = Ext.getCmp('partForm');
form.getForm().reset();
var part = new Pandora.model.Part({
Name: 'my new record'
});
form.loadRecord(part);
},
For loading a new record into the form:
var iUserForm = this.getUserDetailsForm(),
iRecord = Ext.create('BS.model.User');
iUserForm.loadRecord( iRecord );
And upon submit:
var iUserForm = this.getUserDetailsForm();
if (iUserForm.getForm().isValid())
{
var iRecord = iUserForm.getForm().getRecord(),
iValues = iUserForm.getForm().getValues(),
iRecord.set( iValues );
this.getUsersStore().insert(0, iRecord);
}