I have a facilitator defined like this:
{"_id" : "alyssa", "_class" : "entities.profil.FacilitatorEntity","type" : "facilitator","cwsessionsAnime" : [{"$ref" : "cwsession",$id" : "1L"}],
"profilFollowEntity":[{"$ref" : "profil","$id" : "sissa"},
{"$ref" : "profil","$id" : "milou"}]}
and when I click a follow button I will have the id of the user connected added to the profilFollowEntitiy list
I defined ng-click="follow()" and in the controller I declared the method
$scope.follow= function(){
$scope.selectedFac.profilFollowEntity.push({$ref: profil, $id:$scope.user.username});
}
and I have declared a service before profilService.getUser($scope); to get the username of the connected user that I will add to the profilFollowEntity list. The methode .follow() doesn't work, can any one help me please, How could I do that, and thank you in advance
Related
I have an infoBox component in React that needs to be used multiple times.
I have an array of objects.
Each value of the object needs to be passed to the infoBox component leading to the creation of an infoBox.
I am achieving this is by iterating over the object array using map(). I am able to get the output, but I was getting logs in console for unique keys.
Since my object does not have any unique value, I tried using Math.random(). Is it the right approach?
What value do I give for keys, when I do not have unique values in my objects?
userDetails = [{name : "Raj", place : "Chennai"}, {name : "Rani", place : "Mumbai"}, {name : "John", place : "Bengaluru"}]
userDetails.map((user){
return (<InfoBox details = user>);
});
Edit :
userDetails is populated dynamically say based on an organization. When the organization changes, the entire array of objects will be replaced by a new one.
Eg:
userDetails = [{name : "Tom", place : "New York"}, {name : "Pip", place : "Colombo"}, {name : "Davis", place : "Dubai"}]
When you don't have the keys of your object, You can use the index of your loop then doesn't show any warning. It's worked.
You can generate the id with indexOf
userDetails.map((user) => <InfoBox details = {user} key = {userDetails.indexOf(user)}/>)
I have an app with the following DB structure currently, it uses Firebase Database and is on Swift IOS:
"Posts" : {
"Dm8iyaXXdTOJGsymEiLNVO6OdDK2" : {
"post:570915537" : {
"Media" : {
"image" : {
"mediaUrl" : "https://firebaseURL",
"postTimeStamp" : 5.70915539085856E8,
"timeStamp" : 5.7091551482329E8
}, ...
I was now going to add followers to it. I was thinking that I would either add a whole new group:
"Followers" : {
"Dm8iyaXXdTOJGsymEiLNVO6OdDK2" : {
"Following" : {
follower1: "Dm8iyaXXdTOJGsymEiLNVO6OdDK2";
//other followers
}, ...
Or add a new node to the original group and add them there. The last option is to do something similar to what is done above but in the "Users" section.
What is the best course of action?
A follow/unfollow schema using Firestore could be this one:
2 roots collections, one that holds users and another one that holds the following relationship between users through a composite key.
users/{userID}
.. userData
.. followerCount
.. followedCount
following/{followerID_followedID}
.. followerId
.. followedId
.. createdAt
When a userA starts to follow a userB:
set a new document with the id userAuid_userBuid in the
following collection.
triggers a Cloud Function that will run a transaction to update the
counters of both users.
Do the reverse thing when a user stops to follow another user.
In the client, you can know if userA follows userB simply by checking if the document userAuid_userBuid exists inside the following collection.
You can also get the list of a user's followers by querying the collection where the followedId == the current user Id.
Hope that helps you.
I want to mail verify key field value on mail when customer used forgot password option. My query is working perfect. when i debug in view i am able to see filed value but in controller i am not able to access that value.
Here is my controller query.
public function forgot() {
if ($this->User->validates() ) {
$auserlogin = $this->User->forgot($this->data['user']['email']);
$this->set('auserlogin', $auserlogin);
$message="Someone requested to reset password \n\n";
$message=$message."Verify Key : ".$auserlogin['0']['user']['verifykey']."\n\n";
$message=$message."Thanks\n\n";
$Email = new CakeEmail();
$Email->from(array('mail#gmail.in' => 'mail'))
->to($this->data['user']['email'])
->subject('Forgot Password')
->send($message);
return $this->redirect(array('controller'=>'users','action'=>'password'));
}
}
In view part i am able to see query is working via this
$auserlogin['0']['user']['verifykey'];
but i want to mail this verifykey to user so i used
$message="Verify Key : ".$auserlogin['0']['user']['verifykey']."\n\n";
OR
$this->set('verifykey', $auserlogin['0']['user']['verifykey']);
$message="Verify Key : ".$verifykey."\n\n";
both are not working in mail i am not receiving variable value on mail i received only
Verify Key :
Model name should be in capitalised inside controller. $auserlogin['0']['User']['verifykey']
Credit goes newbee-dev
First please apologize myself if I make any typing error (I am french).
Well, I am trainning on Angular JS and I would like to use the filter on one specific field but my problem is that the filter is based on many fieds.
here is my filter:
<div class=main_frame ng-repeat="x in artiste | filter: recherche_artiste">
<h2>x.name </h2><img ng-src={{x.picture}} />
</div>
My problem is that I would like that the filter impact only the artist name and not all the fields of my array "artiste".
in my app.JS, $scope.artiste is an array[100] who contains objects like:
Array[100]
0
:
Object
$$hashKey
:
"object:14"
_id
:
"57252e30bbcf354d21c5fc19"
age
:
38
name
:
"Mccarty Buckner"
picture
:
"http://lorempixel.com/800/500"
proto
:
Object
1
:
Object
$$hashKey
:
"object:15"
_id
:
"57252e304cf25e47b014303e"
age
:
39
name
:
"Nguyen Kane"
picture
:
"http://lorempixel.com/600/400"
proto
:
Object
The problem is when I hit on filter "HTTP" or simply "p" for example, the filter doesn"t work because as you can see above, http is contained in all the the picture field.
Otherwise, the filter works good if I hit "y" for example as there is no "y" in the "picture" fields neither in the _id field.
So my question is, is there any solution to apply my filter only on the "name" field, but keeping the corresponding "picture" field dynamically?
Thanks in advance for your help.
I precise, I am using slowly angular only since a short time ago so I am not an expert:)
ng-repeat="x in artiste | filter: {name : recherche_artiste}"
I am working with a TreePanel/TreeStore in ExtJS 4.1.1, with autoSync enabled and API calls to server endpoints defined via an Ajax proxy.
When a node is created with certain properties set, I have the server automatically add 2 child nodes during the autoSync call to the create API endpoint, and the server response text looks like this:
{
"success" : true,
"errorMsg" : null,
"children" : {
"id" : "toolbox-42",
"parentId" : null,
"itemName" : "My Toolbox",
"nodeType" : "toolbox",
"children" : [{
"id" : "tool-91",
"parentId" : "toolbox-42",
"itemName" : "Default Tool 1",
"nodeType" : "tool",
"leaf" : true,
}, {
"id" : "tool-92",
"parentId" : "toolbox-42",
"itemName" : "Default Tool 2",
"nodeType" : "tool",
"leaf" : true
}
]
}
}
Setting the node's properties via the "children" key at the root level works just fine. The "id" property is set at the inserted node just fine.
My problem is that the child nodes that the server added don't appear in the tree. How do I get these added to the tree view?
Here are some solutions I have considered:
In the server response, make the root level "children" object into an array, and append the new nodes to the end of the array (instead of nesting them under their parent node). The extractData method in Ext.data.reader.Reader (source here) indicates all returned records will be extracted. But, the commitRecords method in Ext.data.Operation (here) only updates the number of clientRecords included in the request, which obviously does not include any new records coming down the pike in the server's response.
After the server's response, manually add the records to the treestore client-side using the "children" node in the server's response. But, there seems to be no easy way to mark these records as "already synced".
Don't add the records on the server at all; instead, manually add them on the client before the sync operation takes place (thus, the sync operation will give the server 3 inserts to do). But, the child nodes in the create request won't have a parentId set, because the server hasn't yet added the parent node and returned the id as a response.
Attach an event handler that will fire once after the server has added the parent node, and then add the child nodes programmatically on the client (which would then be auto-synced to the server). But, this would requires 2 server round trips. Also, the only candidate event I know of is 'write' in Ext.data.TreeStore, and there is no corresponding 'failwrite' event which could be used to remove the listener in case the write operation fails. I could add an abstraction layer to provide that... but I would rather not if Sencha already built a better way.
Any other suggestions? I will accept a suggestion that works or any statement/link describing how Sencha recommends addressing this problem.
Thanks.
UPDATE: My store, proxy, and reader are configured as follows:
var store = Ext.create('Ext.data.TreeStore', {
model : 'App.models.Task',
autoLoad : true,
autoSync : true,
proxy : {
type : 'ajax',
api : {
create : appUrl + 'Data/InsertTreeData',
read : appUrl + 'Data/GetTreeData',
update : appUrl + 'Data/UpdateTreeData',
destroy : appUrl + 'Data/DeleteTreeData'
},
reader : {
type : 'json',
messageProperty : 'errorMsg'
}
}
});
What I do when I add a node to the tree on the server side is grab the parent object id (it could be the root and that is fine) and then run the refreshParent routine that looks like this:
var node = this.store.getNodeById(id);
if (node){
this.store.load({node:node});
}
Context here is the tree panel. This routine reloads specific branch of the tree.