-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
754 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+233 KB
...assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-1inch-blacktitanium.webp
Binary file not shown.
Binary file added
BIN
+257 KB
app/assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-1inch-bluetitanium.webp
Binary file not shown.
Binary file added
BIN
+275 KB
...sets/images/iphone_images/iphone-15-pro-finish-select-202309-6-1inch-naturaltitanium.webp
Binary file not shown.
Binary file added
BIN
+296 KB
...assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-1inch-whitetitanium.webp
Binary file not shown.
Binary file added
BIN
+276 KB
...assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-7inch-blacktitanium.webp
Binary file not shown.
Binary file added
BIN
+307 KB
app/assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-7inch-bluetitanium.webp
Binary file not shown.
Binary file added
BIN
+324 KB
...sets/images/iphone_images/iphone-15-pro-finish-select-202309-6-7inch-naturaltitanium.webp
Binary file not shown.
Binary file added
BIN
+371 KB
...assets/images/iphone_images/iphone-15-pro-finish-select-202309-6-7inch-whitetitanium.webp
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class FeaturesController < ApplicationController | ||
before_action :set_feature, only: %i[ show edit update destroy ] | ||
|
||
# GET /features or /features.json | ||
def index | ||
@features = Feature.all | ||
end | ||
|
||
# GET /features/1 or /features/1.json | ||
def show | ||
end | ||
|
||
# GET /features/new | ||
def new | ||
@feature = Feature.new | ||
end | ||
|
||
# GET /features/1/edit | ||
def edit | ||
end | ||
|
||
# POST /features or /features.json | ||
def create | ||
@feature = Feature.new(feature_params) | ||
|
||
respond_to do |format| | ||
if @feature.save | ||
format.html { redirect_to feature_url(@feature), notice: "Feature was successfully created." } | ||
format.json { render :show, status: :created, location: @feature } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @feature.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /features/1 or /features/1.json | ||
def update | ||
respond_to do |format| | ||
if @feature.update(feature_params) | ||
format.html { redirect_to feature_url(@feature), notice: "Feature was successfully updated." } | ||
format.json { render :show, status: :ok, location: @feature } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @feature.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /features/1 or /features/1.json | ||
def destroy | ||
@feature.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to features_url, notice: "Feature was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_feature | ||
@feature = Feature.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def feature_params | ||
params.require(:feature).permit(:tagline, :descrption, :category, :image_path, :position, :hotel_id) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Hotels::FeaturesController < HotelBaseController | ||
before_action :set_hotel | ||
def index | ||
@features = @hotel.topic_features.order(:position) | ||
end | ||
|
||
def room | ||
@features = @hotel.room_features.order(:position) | ||
end | ||
|
||
private | ||
|
||
def set_hotel | ||
@hotel = Hotel.find(params[:hotel_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class IphonesController < ApplicationController | ||
layout "iphone" | ||
before_action :set_iphone | ||
def show | ||
end | ||
|
||
def create | ||
@iphone.model = params[:model] if params[:model] | ||
@iphone.color = params[:color] if params[:color] | ||
redirect_to iphone_path | ||
end | ||
|
||
private | ||
|
||
def set_iphone | ||
session[:iphone] ||= {} | ||
@iphone = Iphone.new(session[:iphone]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module FeaturesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="image-switcher" | ||
export default class extends Controller { | ||
static values = {iphone: Object} | ||
static targets = ["colorText"] | ||
|
||
connect() { | ||
} | ||
|
||
setColorTitle(event) { | ||
const colorName = event.params.colorName | ||
this.colorTextTargets.forEach(target => target.textContent = colorName) | ||
} | ||
|
||
resetColorTitle(event) { | ||
this.colorTextTargets.forEach(target => target.textContent = this.iphoneValue.color_name) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Feature < ApplicationRecord | ||
belongs_to :hotel | ||
enum :category, [ :topic, :room, :restaurant, :service, :basic_info ] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
class Hotel < ApplicationRecord | ||
has_many :features | ||
has_many :topic_features, -> { where(category: :topic) }, class_name: "Feature" | ||
has_many :room_features, -> { where(category: :room) }, class_name: "Feature" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Iphone | ||
def initialize(iphone_session) | ||
@iphone_session = iphone_session | ||
end | ||
|
||
def model=(string) | ||
@iphone_session['model'] = string | ||
end | ||
|
||
def model | ||
@iphone_session['model'] || "6-1inch" | ||
end | ||
|
||
def color=(string) | ||
@iphone_session['color'] = string | ||
end | ||
|
||
def color | ||
@iphone_session["color"] || "naturaltitanium" | ||
end | ||
|
||
def color_name | ||
color_name_for_value(color) | ||
end | ||
|
||
def color_name_for_value(value) | ||
table = { | ||
"naturaltitanium" => "Color – Natural Titanium", | ||
"bluetitanium" => "Color – Blue Titanium", | ||
"whitetitanium" => "Color – White Titanium", | ||
"blacktitanium" => "Color – Black Titanium", | ||
} | ||
table[value] | ||
end | ||
|
||
def image_path | ||
"iphone_images/iphone-15-pro-finish-select-202309-#{model}-#{color}.webp" | ||
end | ||
|
||
def to_hash | ||
{model:, color:, color_name:} | ||
Check failure on line 41 in app/models/iphone.rb GitHub Actions / lint
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div id="<%= dom_id feature %>"> | ||
<p> | ||
<strong>Tagline:</strong> | ||
<%= feature.tagline %> | ||
</p> | ||
|
||
<p> | ||
<strong>Descrption:</strong> | ||
<%= feature.descrption %> | ||
</p> | ||
|
||
<p> | ||
<strong>Category:</strong> | ||
<%= feature.category %> | ||
</p> | ||
|
||
<p> | ||
<strong>Image path:</strong> | ||
<%= feature.image_path %> | ||
</p> | ||
|
||
<p> | ||
<strong>Position:</strong> | ||
<%= feature.position %> | ||
</p> | ||
|
||
<p> | ||
<strong>Hotel:</strong> | ||
<%= feature.hotel_id %> | ||
</p> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! feature, :id, :tagline, :descrption, :category, :image_path, :position, :hotel_id, :created_at, :updated_at | ||
json.url feature_url(feature, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<%= form_with(model: feature) do |form| %> | ||
<% if feature.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(feature.errors.count, "error") %> prohibited this feature from being saved:</h2> | ||
|
||
<ul> | ||
<% feature.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label :tagline, style: "display: block" %> | ||
<%= form.text_field :tagline %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :descrption, style: "display: block" %> | ||
<%= form.text_field :descrption %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :category, style: "display: block" %> | ||
<%= form.text_field :category %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :image_path, style: "display: block" %> | ||
<%= form.text_field :image_path %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :position, style: "display: block" %> | ||
<%= form.number_field :position %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :hotel_id, style: "display: block" %> | ||
<%= form.text_field :hotel_id %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% content_for :title, "Editing feature" %> | ||
|
||
<h1>Editing feature</h1> | ||
|
||
<%= render "form", feature: @feature %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this feature", @feature %> | | ||
<%= link_to "Back to features", features_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<% content_for :title, "Features" %> | ||
|
||
<h1>Features</h1> | ||
|
||
<div id="features"> | ||
<% @features.each do |feature| %> | ||
<%= render feature %> | ||
<p> | ||
<%= link_to "Show this feature", feature %> | ||
</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= link_to "New feature", new_feature_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @features, partial: "features/feature", as: :feature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% content_for :title, "New feature" %> | ||
|
||
<h1>New feature</h1> | ||
|
||
<%= render "form", feature: @feature %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to features", features_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= render @feature %> | ||
|
||
<div> | ||
<%= link_to "Edit this feature", edit_feature_path(@feature) %> | | ||
<%= link_to "Back to features", features_path %> | ||
|
||
<%= button_to "Destroy this feature", @feature, method: :delete %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "features/feature", feature: @feature |
Oops, something went wrong.