jagi / meteor-astronomy-examples Goto Github PK
View Code? Open in Web Editor NEWHome Page: http://astronomy.meteor.com
License: MIT License
Home Page: http://astronomy.meteor.com
License: MIT License
const DiscountCodes = Class.create({
name: 'DiscountCodes',
fields: {
percent: {
type: Number,
default:1,
validators: [{
type: 'gte',
resolveParam(args) {
return parent(args.doc,level);
}
}]
},
});
export const Widgets = Class.create({
name: 'Widgets',
collection: new Mongo.Collection('widgets'),
behaviors: ['timestamp'],
fields: {
discountCodes:{
type: [DiscountCodes],
default: function () {
return []
}
},
},
});
For forms, I would like to make a helper, e.g. inputElement, so I can use it like this:
{{> input field='firstName'}}
<div>
<label for="firstName">First name {{HERE}}</label>
<input id="firstName" type="text" value="{{firstName}}" class="{{#if hasError 'firstName'}}error{{/if}}" />
</div>
{{#if hasError 'firstName'}}
<div class="error">{{getError 'firstName'}}</div>
{{/if}}
Inside, I would like to have a Label (instead of First name), taken from the object. So, that I don't need to pass it to create input, edit input. How can this be done?
W20150915-16:31:03.427(7)? (STDERR) /Users/user/.meteor/packages/meteor-tool/.1.1.3.dzw9kd++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150915-16:31:03.427(7)? (STDERR) throw(ex);
W20150915-16:31:03.427(7)? (STDERR) ^
W20150915-16:31:03.484(7)? (STDERR) TypeError: Object #<Object> has no method 'findInClass'
W20150915-16:31:03.484(7)? (STDERR) at Object.Astro.utils.findBehavior (packages/jagi:astronomy-behaviors/lib/module/utils.js:2:1)
W20150915-16:31:03.484(7)? (STDERR) at Function.checks.added (packages/jagi:astronomy-behaviors/lib/module/init_class.js:31:1)
W20150915-16:31:03.484(7)? (STDERR) at Function.methods.addBehavior (packages/jagi:astronomy-behaviors/lib/module/init_class.js:69:1)
W20150915-16:31:03.484(7)? (STDERR) at Function.<anonymous> (packages/jagi:astronomy-behaviors/lib/module/init_class.js:87:1)
W20150915-16:31:03.484(7)? (STDERR) at Array.forEach (native)
W20150915-16:31:03.485(7)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20150915-16:31:03.485(7)? (STDERR) at Function.methods.addBehaviors (packages/jagi:astronomy-behaviors/lib/module/init_class.js:86:1)
W20150915-16:31:03.485(7)? (STDERR) at Function.onInitClass (packages/jagi:astronomy-behaviors/lib/module/init_class.js:117:1)
W20150915-16:31:03.485(7)? (STDERR) at packages/jagi:astronomy/lib/core/class.js:81:1
W20150915-16:31:03.485(7)? (STDERR) at packages/jagi:astronomy/lib/core/events.js:55:1
In the example, the Meteor methods doesn't check the type of the argument passed in:
Meteor.methods({
'/user/save': function(user) {
if (user.validate()) {
user.save();
return user;
}
}
};
In such case, I feel the client could easily trick the system by defining the custom user
object. Of course this is just a toy example that is not full-fledged, but I'm wondering if there is a way to ensure that the user
object passed in is in desired format.
I'm now thinking of check the argument with user instanceof User
. Is that sufficient?
Thanks.
I think that the name of the variable user is misleading for understanding this example.
Template.Form.events({
'change input': function(e, tmpl) {
var user = this;
var field = e.currentTarget;
user.set(field.id, field.value);
user.validate(field.id);
}
});
Variable user is mapped to current data context of the template instance. So it is assigned to User, Address or Phone Astro class since this example is handling change input event on Form template level so it is handling that event for nested templates AddressForm and PhoneForm also which have different data context.
=> Errors prevented startup:
While checking for jagi:[email protected]:
error: No compatible binary build found for this package. Contact the package author and ask them to publish it for your platform.
Given all the traction react gets, it would be great to see first-class-citizen react support (react counterparts of the spacebars helpers etc) and accompanying examples.
I'm not yet familiar with react but I'll soon be starting yet another meteor project with which I really want to give react and astronomy a go. I had been waiting for [email protected] for a few months now and I'm excited to try the astronomy+react combo.
Hi, I can se that editing the list of phones is partially implemented. Templates are there but there is no logic. Are you planing to complete the example?
Steps to reproduce:
git clone https://github.com/jagi/meteor-astronomy-examples.git
cd meteor-astronomy-examples
meteor npm install
meteor
Let me know what other details I should provide, thanks!.
It seems that valueAsDate is not supported in Firefox (evidence here and here ). Therefore, in Firefox, the program will always think that the birth date is wrong.
Do you think this is a strong enough reason to switch to another way of converting the date input to a Date() object? I'm concerned that people will try this example in Firefox, and decide that Astronomy is broken when they try to submit the form and it does not work.
Let me know what you think, thanks!
I was trying to integrate this example in one of my project features but I use flow-router with template level subscriptions.
I could not put it to work because I can't get the object data in the events method save.
Moreover with the reactivevar (curValue) i cannot access getValidationErrors et. al..somehow they do not come with the submit.
Is there any issues with Flowrouter when working with this? Any reference I could check besides the flowrouter wiki?
Thank you in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.