mobidonia

mobidonia supports this item

Supported

This author's response time can be up to 2 business days.

287 comments found.

haythoo

haythoo Purchased

Hi Dear,

I wish you can add a way to sort the fields, like I want the name to be first field, then the email then….

for now i did it by modifying your code and adding this in Firestoreadmin.js

//at the top import firestoreschema from "../config/firestoreschema.js"; // then in the end in the processRecords i changed this: var cpa = this.getMeTheFirestorePath(); cpa = cpa.substring(0, cpa.indexOf('/')); /* keysFromFirebase.forEach((key)=>{ if (fields.hasOwnProperty(key)) { fieldsAsArray.push({"theKey":key,"value":fields[key]}) } }); */ Object.keys(firestoreschema[cpa].fields).map(function(key) { fieldsAsArray.push({"theKey":key,"value":fields[key]}) });

So the order of the fields is coming from the order that I have put in the firestoreschema

another thing is the move to the new added record in firestore:

// I have added this code after this.refreshDataAndHideNotification(); //////////////////// var keyToCreate = ""; var _this=this; newElementRef.get().then(function(doc) { keyToCreate = doc.id; }).then(function(){ _this.props.router.push(_this.props.route.path.replace(":sub","")+(_this.props.params&&_this.props.params.sub?_this.props.params.sub:"")+Config.adminConfig.urlSeparator+keyToCreate); }); ///////////////////
haythoo

haythoo Purchased

an edit to make sure the we are going to get the extra fields that we did not put in the schema file:

var cpa = this.getMeTheFirestorePath(); cpa = cpa.substring(0, cpa.indexOf('/')); /* keysFromFirebase.forEach((key)=>{ if (fields.hasOwnProperty(key)) { fieldsAsArray.push({"theKey":key,"value":fields[key]}) } }); */ var key_temp = [] Object.keys(firestoreschema[cpa].fields).map(function(key) { fieldsAsArray.push({"theKey":key,"value":fields[key]}); key_temp.push(key); }); keysFromFirebase.forEach((key)=>{ if (fields.hasOwnProperty(key) && !key_temp.includes(key)) { fieldsAsArray.push({"theKey":key,"value":fields[key]}) } });
haythoo

haythoo Purchased

another code that I have added to protect the original fields from delete, and I mean by the original fields and filed declared in the schema.

var cpa = this.getMeTheFirestorePath(); cpa = cpa.substring(0, cpa.indexOf('/')); var _this2 = this; var key_temp = [] Object.keys(firestoreschema[cpa].fields).map(function(k) { key_temp.push(k); }); if (key_temp.includes(key)) { alert("You can not delete orginal fields!") } else { console.log("Delete "+key); console.log(theLink); if(theLink!=null){ theLink=theLink.replace("/firestoreadmin",""); } if(isNaN(key)){ isItArrayItem=false; } console.log("Is it array: "+isItArrayItem); var firebasePathToDelete=(_this2.props.route.path.replace(ROUTER_PATH,"").replace(":sub",""))+(_this2.props.params&&_this2.props.params.sub?_this2.props.params.sub:"").replace(/\+/g,"/"); if(key!=null){ //firebasePathToDelete+=("/"+key) } console.log("firebasePath for delete:"+firebasePathToDelete); _this2.setState({pathToDelete:theLink?theLink:firebasePathToDelete,isItArrayItemToDelete:isItArrayItem,keyToDelete:theLink?"":key}); window.scrollTo(0, 0); _this2.refs.deleteDialog.show(); }
haythoo

haythoo Purchased

Hi Dear,

I did some modification if your interested to have look at it.

Group fields, now I can put fields in groups, so I can get much better forms orgnization here what I did:

if the firestoreschema I extended the collectionMeta to have this:

var collectionMeta={ "offers":{ "fields":{ "title": "test", "age":33, "email":"test@test.com", "account_number":12, "balance":5000 }, "groups":{ "Info":{ "title": "test", "age":33, "email":"test@test.com", }, "Account":{ "account_number":12, "balance":5000 } }, "collections":[], } }

Then in Firestoreadmin.js I added after the

var newState={}; newState.fieldsAsArray=fieldsAsArray; newState.arrayNames=arrayNames; newState.fields=fields; newState.arrays=arrays; newState.isJustArray=Common.getClass(records)=="Array"; newState.elements=elements; newState.elementsInArray=elementsInArray; newState.directValue=directValue; newState.records=records; newState.isLoading=false;

I added:

//Haythoo - check schema if groups are there var ar = []; var ar_f = new Array(); var count_ar = 0; if ( firestoreschema[cpa].groups != undefined) { newState.groping = true; //console.log("groups",firestoreschema[cpa].groups); Object.keys(firestoreschema[cpa].groups).map(function(key) { console.log("group key ",key) ar.push(key) ar_f.push( [] ) Object.keys(firestoreschema[cpa].groups[ar[count_ar]]).map(function(k) { ar_f[count_ar].push({"theKey":k,"value":fields[k]}) }); count_ar++; }); // console.log("ar is",ar) // console.log("ar_f:", ar_f) newState.ar = ar; newState.ar_f = ar_f; } else newState.groping = false; then I changed the render of fields to {/* FIELDS */} {!this.state.groping&&this.state.fieldsAsArray&&this.state.fieldsAsArray.length>0?(<div><div classname="col-md-12"> <div classname="card"> <a onclick="{()=">{this.refs.simpleDialog.show()}}><div id="addDiv" classname="card-header card-header-icon" data-background-color="purple" style="{{float:"right"}}"> <i classname="material-icons">add</i> </div></a> <form className="form-horizontal"> <div classname="card-header card-header-text" data-background-color="rose"> <h4 classname="card-title">{Common.capitalizeFirstLetter(Config.adminConfig.fieldBoxName)}</h4> </div> { console.log("the fields", this.state.fieldsAsArray)} { console.log("the path",this.getMeTheFirestorePath()) } {this.state.fieldsAsArray?this.state.fieldsAsArray.map((item)=>{ return ( <Fields isFirestore={true} parentKey={null} key={item.theKey+this.state.lastSub} deleteFieldAction={this.deleteFieldAction} updateAction={this.updateAction} theKey={item.theKey} value={item.value} />) }):"" } </form> </div> </div></div>):""} { /*By me - Add fields into groups */} {this.state.groping&&this.state.fieldsAsArray&&this.state.fieldsAsArray.length>0?( <div> {/*start looping the groups*/} {this.state.ar.map((gr)=>{ return( <div classname="col-md-12"> <div classname="card"> {console.log("ddddd",gr)} <form className="form-horizontal"> <div classname="card-header card-header-text" data-background-color="rose"> <h4 classname="card-title">{Common.capitalizeFirstLetter(gr)}</h4> </div> { console.log("cc is",cc)} { console.log("the fields", this.state.ar_f[cc])} { console.log("the path",this.getMeTheFirestorePath()) } {this.state.ar_f[cc]?this.state.ar_f[cc].map((item)=>{ console.log("ittt",item) return ( <Fields isFirestore={true} parentKey={null} key={item.theKey+this.state.lastSub} deleteFieldAction={this.deleteFieldAction} updateAction={this.updateAction} theKey={item.theKey} value={item.value} />) }):"" } {console.log("cc is",cc++)} </form> </div> </div>) })} {/*end looping the groups*/} </div>):""}

I am having trouble installing this on my mac. When I run npm install in the project directory I am getting node-pre-gyp and gyp errors and the following npm errors.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! grpc@1.10.1 install: `node-pre-gyp install—fallback-to-build—library=static_library` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the grpc@1.10.1 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

My node version is v10.4.1 My npm version is v6.1.0 my git version is v 2.15.2 (Apple Git-101.1)

I can solve any errors on this script contact me via skype or email ashishb.jgi@gmail.com

Hi,

I wish to ask before i buy is these functions possible :

(Cloud firestore) 1. I want to disable users from adding or deleting element for a certain collection. They can only edit the existing fields but cannot add a new row (document).

2. Is there a way to disable users from adding a new “field” or key to a collection? This is so that I don’t want them to mess up the schema.

Thanks. These functions are really important to me.

bisiz

bisiz Purchased

Hi,

I’m facing a problem while trying to define my navigation properties. My data structure is like : + collection of Cities (/cities) { ‘uid’=’12345’, ‘primaryData’:{‘name’=’city1’,’country’:’country1’}, ‘secondaryData’:{‘geoloc’:’12345678’,’language’:’lang’} }

How to display primaryData.name and secondaryData.lang in navigation menu?

Thanks in advance for your help.

Hi! Thanks for previous answers. You are very kind. I have a very important question. Please answer as soon as possible.

When I drag table row, all keys in the Firebase path are changing to 0, 1, 2… . I have looked at Table.js , but couldn’t find any line for that function to disable.

I’m facing a problem with paging. It seems pagination for firestore doesn’t work. I’ve set the app config paging size but still doesn’t work.

by
by
by
by
by
by