Coder Social home page Coder Social logo

proto_app's Introduction

Prototype menu-app

Bower Installation - Install "jquery": "~2.1.3", should work fine.

If pushing to a .git endpoint like gh-pages or Heroku, as well as removing bower_components from the root .gitignore, you must also remove dist from the angular-new-router .gitignore.

Or just use the live DEMO

The backend is mocked with angular $httpBackend which can be removed by taking out the MockBackend dependency from app.js.

The prototype uses the AngularJS component style and the new, AngularJS 2.0.0 compatable angular-new-router. Whilst this is still early in development, it makes sense to start to adopt the newer component style, avoiding complete rewrites when angular 1.4.0/2.0.0 become standard. The main HAL client id Hyperagent.

The mock-backend syncs data to localStorage for convenience whilst developing. If in doubt, clear the data with localStorage.clear(). There is also an option to DumpHalData(), that logs the complete, namespaced HAL JSON object to the console for inspection.

Revised database schema:

CREATE TABLE tables (

    id SERIAL NOT NULL PRIMARY KEY,
    name TEXT NOT NULL
)

CREATE TABLE products (

    id SERIAL NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    current_price DECIMAL(18,4) NOT NULL
)

CREATE TABLE table_orders (

    id SERIAL NOT NULL PRIMARY KEY,
    table_id INT NOT NULL,
    product_id INT NOT NULL,
    actual_price DECIMAL(18,4) NOT NULL,
    time_ordered TIMESTAMP NOT NULL
)

CREATE TABLE paid_orders (

    id NOT NULL PRIMARY KEY,
    table_orders_id INT NOT NULL,
    final_amount DECIMAL(18,4) NOT NULL,
    time_paid TIMESTAMP NOT NULL,
    is_paid INT NOT NULL
)

changed product_orders_id -> table_orders_id

Ideal REST interface

HTTP URL Params Response
GET /api/ Returns root which is also the TABLES resource.
GET /api/products/ Returns products resource
GET /api/table_orders/ `filter=[paid unpaid], id_only=bool`
GET /api/table_orders/:table_id `filter=[paid unpaid]`
POST /api/table_orders/ table_id=INT:required, order=Array:required Creates a new table order with the required table_id & array of product IDs
POST /api/paid_orders/ table_order_id:required, final_ammount:required Creates a new entry in the paid orders resource

Notes: currently the HAL-JSON client does not support Angulars $http natively, I have supplied an adapter in ApiService to make this work with the mocked backend, however this does require the result to be re-stringified back into JSON which is a bit wasteful. Perhaps a PR or fork could be made so Hyperagent could support Angular natively in the future.

TO-DO:

  • Complete rest compatibility of $httBackend, with filtering by params. (Current implementation defaults to unpaid table_orders without params for prototype.)
  • Move mock data out of mock-backend into separate JSON files.
  • Add e2e tests for rendered views
  • Add option to split orders
  • Add mandatory and optional product modifiers, probably via a small modal?
  • Create ApiService helpers for loading linked resources, then refactor component controllers.
  • Possibly create a separate transactions service for pay_order, create_order functions, instead of having all business logic chucked in the ApiService
  • Add modal confirming payment has been made when rerouting to the home screen. Will require some sort of flash module that acceps a message as paramater.

proto_app's People

Contributors

nverba avatar

Watchers

James Cloos avatar  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.