Giter Club home page Giter Club logo

library-app's Introduction

Ember.js 2.4 Tutorial - Demo Application

Updated: 29 Feb 2016

This is the original repository of the Library App.

For detailed, step by step implementation click here: Ember.js 2 tutorial

Live demo: library-app.firebaseapp.com

How can you run this application locally?

I assume, you have Node.js on your computer. Node.js installation

  • Please create an app on Firebase first. You can register there with one click and create a new app. You have to setup this app name in config/environment.js. (This will be your own cloud based database.)

  • Clone this repository in your project folder

$ git clone [email protected]:zoltan-nz/library-app.git
  • Change to the application directory
$ cd library-app
  • Install node and bower packages
$ npm install && bower install
  • Setup in config/environment.js file your Firebase app name. This will be your own database server.
// config/environment.js
firebase: 'https://YOUR-FIREBASE-APP-NAME-COMES-HERE.firebaseio.com/',
  • Launch the application with Ember server.
$ ember server
  • Open the application in your browser
$ open http://localhost:4200

Managing Books

Simple list and edit the title

Template (books.hbs):

<h1>Books</h1>

<table class="table table-bordered table-striped">
  <thead>
  <tr>
    <th class="vtop">Author</th>
    <th>
      Title
      <br><small class="small not-bold">(Click on the title for editing)</small>
    </th>
    <th class="vtop">Release Year</th>
    <th class="vtop">Library</th>
  </tr>
  </thead>
  <tbody>
  {{#each model as |book|}}
    <tr>

      <td>
        {{book.author.name}}
      </td>

      <td>
        {{#if book.isEditing}}
          <form {{action 'saveBook' book on='submit'}} class="form-inline">
            <div class="input-group">
              {{input value=book.title class='form-control'}}
              <div class="input-group-btn">
                <button type="submit" class="btn btn-success" disabled={{book.isNotValid}}>Save</button>
                <button class="btn btn-danger" {{action 'cancelBookEdit' book}}>Cancel</button>
              </div>
            </div>
          </form>
        {{else}}
          <span {{action 'editBook' book}}>{{book.title}}</span>
        {{/if}}
      </td>

      <td>{{book.releaseYear}}</td>
      <td>{{book.library.name}}</td>
    </tr>
  {{/each}}
  </tbody>
</table>

Route (books.js):

import Ember from 'ember';

export default Ember.Route.extend({

  model() {
    return this.store.findAll('book');
  },

  actions: {

    editBook(book) {
      book.set('isEditing', true);
    },

    cancelBookEdit(book) {
      book.set('isEditing', false);
      book.rollbackAttributes();
    },

    saveBook(book) {
      if (book.get('isNotValid')) {
        return;
      }

      book.set('isEditing', false);
      book.save();
    }
  }
});

library-app's People

Contributors

zoltan-nz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.