These are chat archives for reactioncommerce/reaction

5th
Feb 2015
lovetostrike
@lovetostrike
Feb 05 2015 00:51 UTC
Can any autoForm expert help me out with creating admin setting form? basically, I want to have seperate sections with titles 'Facebook', 'Twitter' etc and their own entries. But I get too much recursion error if I use object. Currently I have
`ReactionCore.Schemas.Socials = new SimpleSchema
  facebook:
    type: Object
    optional: true
  'facebook.appId':
    type: String
    optional: true
    label: 'Facebook App Id'
  twitter:
    type: Object
    optional: true
  'twitter.accountName':
    type: String
    optional: true
    label: 'Twitter Account Name'
{{> afQuickField name='socials.facebook.appId'}}
        {{> afQuickField name='socials.twitter.accountName'}}
Referencing to children works as expected but I want to pass in socials.facebook to give facebook object with title 'Facebook'
Aaron Judd
@aaronjudd
Feb 05 2015 00:55 UTC
I usually define a seperate schema for the object :
ReactionCore.Schemas.SocialFacebook  = new  SimpleSchema
then make the type: ReactionCore.Schemas.SocialFacebook
lovetostrike
@lovetostrike
Feb 05 2015 00:56 UTC
hm, I was thinking I was going too far if I do that, if it works well, I will try tht
Aaron Judd
@aaronjudd
Feb 05 2015 00:57 UTC
I like to force the thought “can this be reusable"
ie: could it be a generic “Schemas.SocialProvider"
lovetostrike
@lovetostrike
Feb 05 2015 00:58 UTC
yea, it should be generic to account for future extensions, we can't write new schema for everything
Aaron Judd
@aaronjudd
Feb 05 2015 00:59 UTC
can always have a blackbox object in the schema that you could save auth / response objects that you can’t account for now
lovetostrike
@lovetostrike
Feb 05 2015 01:02 UTC
I will look into it
saw the type blackbox in the autoform/simpleschema doc
Everest Liu
@evliu
Feb 05 2015 18:28 UTC
question: in a server method, i’m calling var cart = ReactionCore.Collections.Cart.findOne(cart._id), the cart object is there, but when i call cart.cartTotal(), i get “has no method ‘cartTotal’”, clues?
but i see cartTotal in the object when i debug it
Aaron Judd
@aaronjudd
Feb 05 2015 18:28 UTC
ReactionCore.Collections.Cart.findOne(cart._id).cartTotal()
Everest Liu
@evliu
Feb 05 2015 18:28 UTC
ahh, it’s a class method and not an instance method?
Aaron Judd
@aaronjudd
Feb 05 2015 18:29 UTC
when called in a template just use ‘cartTotal’, when call in script reference cartTotal()
it’s a method, not a field, give that a shot
Everest Liu
@evliu
Feb 05 2015 18:29 UTC
mainly because i’m calling a bunch of the methods, but I don’t want to keep quering the db for each one (ie cartSubtotal, cartShipping)
Aaron Judd
@aaronjudd
Feb 05 2015 18:31 UTC
should be ok - it’s getting called from the cartIcon anyhow, so it’s going to be updated locally already
Everest Liu
@evliu
Feb 05 2015 18:31 UTC
i’m calling it server-side
because i see in the copyCartToOrder server method that it stores it into cart, and calls things like cart.cartSubTotal() and soforth
is there a difference if i use findOne vs. find.fetch?
Aaron Judd
@aaronjudd
Feb 05 2015 18:33 UTC
yup, should be ok server side as well. findOne returns an array not a cursor, fetch converts to array, but why do that if you know you only need one ;-)
Everest Liu
@evliu
Feb 05 2015 18:34 UTC
haha, got it, all the little caveats
i’m looking at where it’s all defined in the collection.coffee file; where can i read more about this magical transform function?
Aaron Judd
@aaronjudd
Feb 05 2015 18:37 UTC
yeah, that’s a bit of magic. http://docs.meteor.com/#/full/mongo_collection (see transform)
Everest Liu
@evliu
Feb 05 2015 18:38 UTC
thx for the link [:
Aaron Judd
@aaronjudd
Feb 05 2015 18:41 UTC
that was one of those.. didn’t exist, then did exist, used it a little, but still had other code using collection helpers which was essentially the same thing…. so just merged them when I redid the cart mechanism… I wanted the cart values to be reactive and just part of the collection, the registerHelpers method didn’t feel right, so this magic
goal 2, I didn’t want to actually store the values… in case of intercept, changes, I wanted to make sure we were trully calculating the cart
so you can’t actually store or update those values
Everest Liu
@evliu
Feb 05 2015 19:05 UTC
i would probably go the same route
Everest Liu
@evliu
Feb 05 2015 19:49 UTC
is there a schema for the user for the extra fields?
Aaron Judd
@aaronjudd
Feb 05 2015 20:10 UTC
I don’t think so, I don’t think I did because it’s from the meteor accounts package. Maybe we should though...
Everest Liu
@evliu
Feb 05 2015 20:10 UTC
it’s still being extended with things like addressBook and emails, so long as we document what is extended
is anyone getting each address shown twice in the checkout screen for each address?
Aaron Judd
@aaronjudd
Feb 05 2015 20:13 UTC
no, just 1 ship to, 1 bill to, per address
Everest Liu
@evliu
Feb 05 2015 20:14 UTC
hmm, maybe i broke something; more debugging… such is the life of a developer
ohh, maybe because i don’t see any label for shipping and billing
maybe something wrong with my i18n
Aaron Judd
@aaronjudd
Feb 05 2015 20:18 UTC
do you go back through the checkout every time, or do you refresh, or just hot reload? I know it’s a weird thing to test, but that’s how I check it. (all three) because there are still some lingering reliance on the session being in the correct state for checkout to reload things correctly
Everest Liu
@evliu
Feb 05 2015 20:19 UTC
mainly refresh and hot reload
yea, doesn’t look like i18n helper is working for me
addressBook.html — i see <span data-i18n=… in line 13 but {{i18n ‘nameOf.key’}}, are there differences between the two?
Aaron Judd
@aaronjudd
Feb 05 2015 20:20 UTC
i18n should fall back to text in the template if it fails
they should both return the same text, but my preferred method is <span data-i18n>Text</span>
Everest Liu
@evliu
Feb 05 2015 20:22 UTC
alright, line 21 doesn’t have the Text fallback
<strong>{{i18n 'addressBookGrid.selectShippingAddress'}}</strong>
also getting update failed: MongoError: Field name duplication not allowed with modifiers in the console, not sure what’s throwing it
Aaron Judd
@aaronjudd
Feb 05 2015 20:24 UTC
ah, yes.. and 42.. but that should still work, you could try using the span and see if that fixes it
Everest Liu
@evliu
Feb 05 2015 20:25 UTC
will do; if it’s working for you, then i just gotta figure out why it doesn’t for me
it works with the <span> even when i don’t write any text in the span
Aaron Judd
@aaronjudd
Feb 05 2015 20:26 UTC
just a sec, testing myself
yeah, strange but it’s working fine for me, but I guess it makes sense to change to <span>. I don’t think I had some secret feature tied to that code (but who knows, lol)
Everest Liu
@evliu
Feb 05 2015 20:28 UTC
lol
yea, always good to be consistent
i’ll PR
Aaron Judd
@aaronjudd
Feb 05 2015 20:28 UTC
:thumbsup:
Everest Liu
@evliu
Feb 05 2015 20:32 UTC
reactioncommerce/reaction-core#88
Everest Liu
@evliu
Feb 05 2015 22:25 UTC
in the users.json fixture, within address, i see isDefault; question: should we separate it out into isBillingDefault and isShippingDefault flags?
Aaron Judd
@aaronjudd
Feb 05 2015 22:27 UTC
hmmm, I guess that would make it more flexible. as long as the default user cart workflow is: add one address, default by default, and it’s already selected, it wouldn’t hurt to add a default to both of them
Everest Liu
@evliu
Feb 05 2015 22:32 UTC
i just realized there is also a Customer schema… and i’m guessing it’s not attached to the user object either… would the Customer schema be a sub-doc of the User obj?
Everest Liu
@evliu
Feb 05 2015 22:44 UTC
and going forward, for multi-vendor, instead of one shopId, it could be an array of shopIds, but the end goal for us is something like etsy: one customer that can shop at any of the shops
Bogi
@boboci9
Feb 05 2015 23:50 UTC
In this case we if we use isBillingDefault and isShippingDefault, just to be sure that we only have one address set to default for each at every time we should add extra security before the address update, and set the rest of the addresses false, don't we? If yes, where do you suggest adding this ?
Aaron Judd
@aaronjudd
Feb 05 2015 23:53 UTC
I think there is some client side logic for that already, just needs to be reused. I’m not sure however if there is anything serverside checking that, and it probably should be moved to the collection or schema level
@evliu that’s the original design for shopIds, which should be enforced on every collection
Everest Liu
@evliu
Feb 05 2015 23:55 UTC
hmm, i c. i just say it because in customers.coffee, the shopId is set to type:string, rather than shopIds (the emphasis on it being plural)
Aaron Judd
@aaronjudd
Feb 05 2015 23:55 UTC
@evliu re: Customer schema… it’s not attached but that’s what I had intended, never got around to finishing, and it’s just been dangling there since we’re just using user
Everest Liu
@evliu
Feb 05 2015 23:56 UTC
got it, so maybe we can attach the Customer schema to a Customer document within the user document with just the necessary info