I’ve, now, been working on Ember for two solid weeks to learn the it and get some simple things going. I have a decent amount of programming experience (multiple years, multiple languages) and Ember is, well, a mess.
I’ve managed to string together a simple application calling a RESTful service and getting some returns to display. Cool. But, as already said, the documentation is woefully incomplete and misleadingly simple all.over.the.place. Trying to get the ember-calendar addon working in a clean build has been an absolute nightmare… much less trying to actually add it to my other working project.
Or, well, maybe I just over-estimate my capabilities. I don’t know at this point. Here’s what I’ve done.
#Attempt #1:
ember new cal-test
ember install ember-calendar
ember generate template index
###Paste in code as per page:
{{as-calendar
title="Ember Calendar"
occurrences=occurrences
defaultTimeZoneQuery="New York|London|Dubai|Hong Kong"
dayStartingTime="9:00"
dayEndingTime="18:00"
timeSlotDuration="00:30"
onAddOccurrence="calendarAddOccurrence"
onUpdateOccurrence="calendarUpdateOccurrence"
onRemoveOccurrence="calendarRemoveOccurrence"}}
###then:
ember generate controller index
###Paste in code as per page:
import Ember from 'ember';
export default Ember.Controller.extend({
occurrences: Ember.A(),
actions: {
calendarAddOccurrence: function(occurrence) {
this.get('occurrences').pushObject(Ember.Object.create({
title: occurrence.get('title'),
startsAt: occurrence.get('startsAt'),
endsAt: occurrence.get('endsAt')
}));
},
calendarUpdateOccurrence: function(occurrence, properties) {
occurrence.setProperties(properties);
},
calendarRemoveOccurrence: function(occurrence) {
this.get('occurrences').removeObject(occurrence);
}
}
});
###Build it.
ember build
###See the error page doesn’t render.:
Error: Cannot find module '/cal-test/node_modules/broccoli-sass'
###Ok, lets install broccoli sass. I’ll probably need ember-cli-sass as well, but lets see.
npm install --save-dev ember-cli-sass
###New error:
app/styles/app.[scss|sass] does not exist
###Fix it:
mv app/styles/app.css app/styles/app.scss
###Add in the style:
app.scss: @import 'addons/ember-calendar/main';
###Add the paint addon:
ember install ember-cli-paint
###Conflict, unable to find jquery: Select Option #1: jquery ^1.11.1
###Content security violations, remove it from package.json
package.json: -"ember-cli-content-security-policy": "0.4.0",
###Deprecation errors: [Deprecated] this.pickFiles is deprecated, please use broccoli-funnel directly instead [addon: liquid-fire] [Deprecated] this.mergeTrees is deprecated, please use broccoli-merge-trees directly instead [addon: liquid-fire]
###Go here and fix it:
https://github.com/ef4/liquid-fire/commit/cbf79b66f31e6bb700a8b417350f283f2a0336db
###Missing modules, ‘broccoli-merge-trees’, ‘broccoli-static-compiler’:
npm install --save-dev broccoli-merge-trees
npm install --save-dev broccoli-static-compiler
###File error:
File: cal-test/templates/application.hbs
TypeError: Cannot read property 'path' of undefined
at TransformLiquidWithAsToHash.TransformWithAsToHash_validate [as validate] (cal-test/node_modules/liquid-fire/ext/plugins/transform-liquid-with-as-to-hash.js:45:15)
###The code in question:
TransformLiquidWithAsToHash.prototype.validate = function TransformWithAsToHash_validate(node) {
return node.type === 'BlockStatement' &&
node.sexpr.path.original === 'liquid-with' &&
node.sexpr.params.length === 3 &&
node.sexpr.params[1].type === 'PathExpression' &&
node.sexpr.params[1].original === 'as';
};
And, stuck.
Should it really be this difficult / sloppy to get this running from a clean build?
I feel like I’m missing something easy.
#Attempt #2 (works):
git clone https://github.com/alphasights/ember-calendar.git
npm install
bower install
###Still has an error:
DEPRECATION: Using `{{view}}` or any path based on it ('dummy/templates/components/liquid-modal.hbs' @ L4:C6) has been deprecated.
Now, even though Attempt #2 has something up and running, the format of the project cannot easily be used or integrated with the previous work that I did to get my RESTful services working.
It shouldn’t be this hard to do a vanilla application and install an addon, should it?
I wonder how hard this would be in another framework… should I go find out?
Thanks for any comments / help.