diff --git a/Gemfile b/Gemfile
index 0854276a..588f8e3c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,6 +20,9 @@ gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
+gem 'simple_form'
+gem 'bootstrap', '~> 4.0.0.alpha3'
+
# Use jquery as the JavaScript library
gem 'jquery-rails'
@@ -48,6 +51,7 @@ group :development do
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'rspec-rails', '~> 3.5'
+ gem 'schema_to_scaffold'
end
group :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index 399c6bf9..ec778c00 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -39,6 +39,11 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
+ autoprefixer-rails (6.7.7)
+ execjs
+ bootstrap (4.0.0.alpha6)
+ autoprefixer-rails (>= 6.0.3)
+ sass (>= 3.4.19)
builder (3.2.3)
byebug (9.0.6)
coffee-rails (4.2.1)
@@ -145,8 +150,13 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
+ schema_to_scaffold (0.8.0)
+ activesupport (>= 3.2.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
+ simple_form (3.4.0)
+ actionpack (> 4, < 5.1)
+ activemodel (> 4, < 5.1)
spring (2.0.1)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
@@ -182,6 +192,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ bootstrap (~> 4.0.0.alpha3)
byebug
coffee-rails (~> 4.2)
database_cleaner
@@ -195,7 +206,9 @@ DEPENDENCIES
rails (~> 5.0.2)
rspec-rails (~> 3.5)
sass-rails (~> 5.0)
+ schema_to_scaffold
shoulda-matchers (~> 3.1)
+ simple_form
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index b12018d0..3009bd15 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
+//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require_tree .
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
deleted file mode 100644
index 0ebd7fe8..00000000
--- a/app/assets/stylesheets/application.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * This is a manifest file that'll be compiled into application.css, which will include all the files
- * listed below.
- *
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
- *
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
- * files in this directory. Styles in this file should be added after the last require_* statement.
- * It is generally better to create a new file per style scope.
- *
- *= require_tree .
- *= require_self
- */
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
new file mode 100644
index 00000000..cbd46a7a
--- /dev/null
+++ b/app/assets/stylesheets/application.scss
@@ -0,0 +1 @@
+@import "bootstrap";
diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss
new file mode 100644
index 00000000..4ce42667
--- /dev/null
+++ b/app/assets/stylesheets/scaffolds.scss
@@ -0,0 +1,89 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+ margin: 33px;
+}
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+ margin: 33px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a {
+ color: #000;
+
+ &:visited {
+ color: #666;
+ }
+
+ &:hover {
+ color: #fff;
+ background-color: #000;
+ }
+}
+
+th {
+ padding-bottom: 5px;
+}
+
+td {
+ padding-bottom: 7px;
+ padding-left: 5px;
+ padding-right: 5px;
+}
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px;
+ }
+}
+
+#notice {
+ color: green;
+}
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0;
+ background-color: #c00;
+ color: #fff;
+ }
+
+ ul li {
+ font-size: 12px;
+ list-style: square;
+ }
+}
+
+label {
+ display: block;
+}
diff --git a/app/models/setup.rb b/app/models/setup.rb
new file mode 100644
index 00000000..7fa40095
--- /dev/null
+++ b/app/models/setup.rb
@@ -0,0 +1,5 @@
+module Setup
+ def self.table_name_prefix
+ 'setup_'
+ end
+end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 82497a53..dd40fa29 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
- SXRestaurants
+ Film Buff
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
@@ -9,6 +9,12 @@
- <%= yield %>
+ <%= render 'layouts/header' %>
+
+ <% flash.each do |name, msg| %>
+ <%= content_tag(:div, msg, class: "alert alert-info") %>
+ <% end %>
+ <%= yield %>
+
diff --git a/app/views/layouts/header.html.erb b/app/views/layouts/header.html.erb
new file mode 100644
index 00000000..418f02e7
--- /dev/null
+++ b/app/views/layouts/header.html.erb
@@ -0,0 +1,16 @@
+
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
new file mode 100644
index 00000000..f306c195
--- /dev/null
+++ b/config/initializers/simple_form.rb
@@ -0,0 +1,169 @@
+# Use this setup block to configure all options available in SimpleForm.
+SimpleForm.setup do |config|
+ # Wrappers are used by the form builder to generate a
+ # complete input. You can remove any component from the
+ # wrapper, change the order or even add your own to the
+ # stack. The options given below are used to wrap the
+ # whole input.
+ config.wrappers :default, class: :input,
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
+ ## Extensions enabled by default
+ # Any of these extensions can be disabled for a
+ # given input by passing: `f.input EXTENSION_NAME => false`.
+ # You can make any of these extensions optional by
+ # renaming `b.use` to `b.optional`.
+
+ # Determines whether to use HTML5 (:email, :url, ...)
+ # and required attributes
+ b.use :html5
+
+ # Calculates placeholders automatically from I18n
+ # You can also pass a string as f.input placeholder: "Placeholder"
+ b.use :placeholder
+
+ ## Optional extensions
+ # They are disabled unless you pass `f.input EXTENSION_NAME => true`
+ # to the input. If so, they will retrieve the values from the model
+ # if any exists. If you want to enable any of those
+ # extensions by default, you can change `b.optional` to `b.use`.
+
+ # Calculates maxlength from length validations for string inputs
+ # and/or database column lengths
+ b.optional :maxlength
+
+ # Calculate minlength from length validations for string inputs
+ b.optional :minlength
+
+ # Calculates pattern from format validations for string inputs
+ b.optional :pattern
+
+ # Calculates min and max from length validations for numeric inputs
+ b.optional :min_max
+
+ # Calculates readonly automatically from readonly attributes
+ b.optional :readonly
+
+ ## Inputs
+ b.use :label_input
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
+ b.use :error, wrap_with: { tag: :span, class: :error }
+
+ ## full_messages_for
+ # If you want to display the full error message for the attribute, you can
+ # use the component :full_error, like:
+ #
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
+ end
+
+ # The default wrapper to be used by the FormBuilder.
+ config.default_wrapper = :default
+
+ # Define the way to render check boxes / radio buttons with labels.
+ # Defaults to :nested for bootstrap config.
+ # inline: input + label
+ # nested: label > input
+ config.boolean_style = :nested
+
+ # Default class for buttons
+ config.button_class = 'btn'
+
+ # Method used to tidy up errors. Specify any Rails Array method.
+ # :first lists the first message for each field.
+ # Use :to_sentence to list all errors for each field.
+ # config.error_method = :first
+
+ # Default tag used for error notification helper.
+ config.error_notification_tag = :div
+
+ # CSS class to add for error notification helper.
+ config.error_notification_class = 'error_notification'
+
+ # ID to add for error notification helper.
+ # config.error_notification_id = nil
+
+ # Series of attempts to detect a default label method for collection.
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
+
+ # Series of attempts to detect a default value method for collection.
+ # config.collection_value_methods = [ :id, :to_s ]
+
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
+ # config.collection_wrapper_tag = nil
+
+ # You can define the class to use on all collection wrappers. Defaulting to none.
+ # config.collection_wrapper_class = nil
+
+ # You can wrap each item in a collection of radio/check boxes with a tag,
+ # defaulting to :span.
+ # config.item_wrapper_tag = :span
+
+ # You can define a class to use in all item wrappers. Defaulting to none.
+ # config.item_wrapper_class = nil
+
+ # How the label text should be generated altogether with the required text.
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
+
+ # You can define the class to use on all labels. Default is nil.
+ # config.label_class = nil
+
+ # You can define the default class to be used on forms. Can be overriden
+ # with `html: { :class }`. Defaulting to none.
+ # config.default_form_class = nil
+
+ # You can define which elements should obtain additional classes
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
+
+ # Whether attributes are required by default (or not). Default is true.
+ # config.required_by_default = true
+
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
+ # These validations are enabled in SimpleForm's internal config but disabled by default
+ # in this configuration, which is recommended due to some quirks from different browsers.
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
+ # change this configuration to true.
+ config.browser_validations = false
+
+ # Collection of methods to detect if a file type was given.
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
+
+ # Custom mappings for input types. This should be a hash containing a regexp
+ # to match as key, and the input type that will be used when the field name
+ # matches the regexp as value.
+ # config.input_mappings = { /count/ => :integer }
+
+ # Custom wrappers for input types. This should be a hash containing an input
+ # type as key and the wrapper that will be used for all inputs with specified type.
+ # config.wrapper_mappings = { string: :prepend }
+
+ # Namespaces where SimpleForm should look for custom input classes that
+ # override default inputs.
+ # config.custom_inputs_namespaces << "CustomInputs"
+
+ # Default priority for time_zone inputs.
+ # config.time_zone_priority = nil
+
+ # Default priority for country inputs.
+ # config.country_priority = nil
+
+ # When false, do not use translations for labels.
+ # config.translate_labels = true
+
+ # Automatically discover new inputs in Rails' autoload path.
+ # config.inputs_discovery = true
+
+ # Cache SimpleForm inputs discovery
+ # config.cache_discovery = !Rails.env.development?
+
+ # Default class for inputs
+ # config.input_class = nil
+
+ # Define the default class of the input wrapper of the boolean input.
+ config.boolean_label_class = 'checkbox'
+
+ # Defines if the default input wrapper class should be included in radio
+ # collection wrappers.
+ # config.include_default_input_wrapper_class = true
+
+ # Defines which i18n scope will be used in Simple Form.
+ # config.i18n_scope = 'simple_form'
+end
diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb
new file mode 100644
index 00000000..c7705e8e
--- /dev/null
+++ b/config/initializers/simple_form_bootstrap.rb
@@ -0,0 +1,154 @@
+# Use this setup block to configure all options available in SimpleForm.
+SimpleForm.setup do |config|
+ config.error_notification_class = 'alert alert-danger'
+ config.button_class = 'btn btn-default'
+ config.boolean_label_class = nil
+
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :minlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+
+ b.use :input, class: 'form-control'
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :minlength
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+
+ b.use :input
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
+ ba.use :label_input
+ end
+
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+ b.use :input
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :minlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input, class: 'form-control'
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :minlength
+ b.optional :readonly
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
+ ba.use :label_input
+ end
+
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :minlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'sr-only'
+
+ b.use :input, class: 'form-control'
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+ b.wrapper tag: 'div', class: 'form-inline' do |ba|
+ ba.use :input, class: 'form-control'
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
+ # Check the Bootstrap docs (http://getbootstrap.com)
+ # to learn about the different styles for forms and inputs,
+ # buttons and other elements.
+ config.default_wrapper = :vertical_form
+ config.wrapper_mappings = {
+ check_boxes: :vertical_radio_and_checkboxes,
+ radio_buttons: :vertical_radio_and_checkboxes,
+ file: :vertical_file_input,
+ boolean: :vertical_boolean,
+ datetime: :multi_select,
+ date: :multi_select,
+ time: :multi_select
+ }
+end
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
new file mode 100644
index 00000000..23743833
--- /dev/null
+++ b/config/locales/simple_form.en.yml
@@ -0,0 +1,31 @@
+en:
+ simple_form:
+ "yes": 'Yes'
+ "no": 'No'
+ required:
+ text: 'required'
+ mark: '*'
+ # You can uncomment the line below if you need to overwrite the whole required html.
+ # When using html, text and mark won't be used.
+ # html: '*'
+ error_notification:
+ default_message: "Please review the problems below:"
+ # Examples
+ # labels:
+ # defaults:
+ # password: 'Password'
+ # user:
+ # new:
+ # email: 'E-mail to sign in.'
+ # edit:
+ # email: 'E-mail.'
+ # hints:
+ # defaults:
+ # username: 'User name to sign in.'
+ # password: 'No special characters, please.'
+ # include_blanks:
+ # defaults:
+ # age: 'Rather not say'
+ # prompts:
+ # defaults:
+ # age: 'Select your age'
diff --git a/config/routes.rb b/config/routes.rb
index 7ae7e768..1975bbab 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
+
namespace :api, :defaults => { :format => 'json' } do
#Session Login and Logout
@@ -13,5 +14,7 @@ Rails.application.routes.draw do
end
+
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
diff --git a/db/scaffold_structure b/db/scaffold_structure
new file mode 100644
index 00000000..175751d0
--- /dev/null
+++ b/db/scaffold_structure
@@ -0,0 +1,20 @@
+
+rails generate scaffold_controller Setup/Lookup lookup_type:string name:string value:string --no-migration
+rails generate scaffold_controller Setup/Employee name:string role:string encrypted_access_code:string --no-migration
+
+rails generate scaffold_controller Setup/Customer name:string company:string contact_no:string email:string membership:references membership_type:string membership_authentication_code:string --no-migration
+rails generate scaffold_controller Setup/Zone name:string is_active:boolean created_by:string --no-migration
+rails generate scaffold_controller Setup/DiningFacility zone:references name:string status:string type:string seater:integer order_by:integer created_by:string is_active:boolean --no-migration
+
+rails generate scaffold_controller Setup/Menu name:string is_active:boolean valid_days:string valid_time_from:time valid_time_to:time created_by:string --no-migration
+
+rails generate scaffold_controller Setup/MenuCategory menu:references name:string alt_name:string order_by:integer menu_category:references --no-migration
+rails generate scaffold_controller Setup/MenuItem item_code:string name:string alt_name:string type:string menu_category:references menu_item:references min_selectable_item:integer max_selectable_item:integer options:json attributes:json created_by:string --no-migration
+
+rails generate scaffold_controller Setup/OrderQueueProcessByZone order_queue_station:references zone:references --no-migration
+rails generate scaffold_controller Setup/OrderQueueStation station_name:string is_active:boolean processing_items:json print_copy:boolean printer_name:string font_size:integer cut_per_item:boolean use_alternate_name:boolean created_by:string --no-migration
+
+rails generate scaffold_controller Setup/PaymentMethodSetting payment_method:string is_active:boolean gateway_communication_type:string gateway_url:string auth_token:string merchant_account:references --no-migration
+
+rails generate scaffold Setup/TaxProfile name:string rate:decimal inclusive:boolean order_by:integer created_by:string --no-migration --skip-model
+rails generate scaffold_controller Setup/CashierTerminal name:string is_active:boolean is_currently_login:boolean auto_print_receipt:string printer_name:string header:json footer:json font:string font_size:string show_tax:boolean show_cashier:boolean show_guest_info:boolean --no-migration
diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb
new file mode 100644
index 00000000..201a069e
--- /dev/null
+++ b/lib/templates/erb/scaffold/_form.html.erb
@@ -0,0 +1,13 @@
+<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
+ <%%= f.error_notification %>
+
+
+ <%- attributes.each do |attribute| -%>
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
+ <%- end -%>
+
+
+
+ <%%= f.button :submit %>
+
+<%% end %>