Skip to content

Commit

Permalink
填充数据,完善逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyc-z committed Aug 24, 2017
1 parent 36f9b5f commit 432f7c4
Show file tree
Hide file tree
Showing 29 changed files with 316 additions and 87 deletions.
3 changes: 2 additions & 1 deletion app/assets/stylesheets/apps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
@import "plats/new";
@import "plats/show";

@import "pkgs/show";
@import "pkgs/show";
@import "pkgs/new";
56 changes: 46 additions & 10 deletions app/assets/stylesheets/apps/index.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
.app.index{
&.app-host-container{
margin-top: 20px;
@media (min-width: 901px){
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-content: flex-start;
margin-top: 20px;
.cell{
overflow: hidden;
$icon_with : 100px;
margin-bottom: 20px;
position: relative;
&.new{
.cell-container{
border: solid 1px #337ab7;
}
}
.actions{
position: relative;
top: -32px;
right: 12px;
}
.divider{
display: none;
}
Expand All @@ -35,12 +36,25 @@
img{
width: 100%;
}
.text-icon{
width: 100%;
height: 100%;
background-color: #03A3FC;
span{
display: block;
width: 100%;
text-align: center;
line-height: $icon_with;
font-size: 40px;
color: #fff;
}
}
}
.detail{
display: block;
width:-moz-calc(100% - 48px);
/* width:-moz-calc(100% - 48px);
width:-webkit-calc(100% - 48px);
width: calc(100% - 48px);
width: calc(100% - 48px);*/
.title{
display: block;
width: 100%;
Expand All @@ -49,11 +63,16 @@
.date-label{
float: right;
font-size: 13px;
color: #999999;
color: #999;
}
.sub-title{
color: #666666;
display: block;
color: #777;
font-size: 13px;
line-height: 24px;
}
.halving-line{
color: #999;
}
}
}
Expand Down Expand Up @@ -87,6 +106,20 @@
img{
width: 100%;
}
.text-icon{
width: 100%;
height: 100%;
background-color: #03A3FC;
span{
display: block;
width: 100%;
text-align: center;
line-height: $icon_with;
font-size: 28px;
color: #fff;
font-weight: lighter;
}
}
}
.detail{
display: block;
Expand All @@ -111,6 +144,9 @@
color: #666666;
font-size: 13px;
}
.halving-line{
display: none;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/apps/new.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.app.new{
.new_app{
.new_app,.edit_app{
margin: 0 auto;
border: solid 1px #ddd;
width: 360px;
Expand Down Expand Up @@ -32,6 +32,7 @@
}
input[type=submit]{
margin: 0 auto;
width: 100%;
}
}
}
38 changes: 38 additions & 0 deletions app/assets/stylesheets/pkgs/new.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.pkgs.new{
.new_pkg{
margin: 0 auto;
border: solid 1px #ddd;
width: 360px;
margin-top: 16%;
border-radius: 4px;
box-sizing: border-box;
padding: 12px;
background-color: #fff;
@media (max-width: 900px){
width: 100%;
}
.title{
border-bottom: solid 1px #ddd;
font-size: 18px;
color: #03A3FC;
font-weight: normal;
span{
border-bottom: solid 1px #03A3FC;
line-height: 34px;
display: inline-block;
}
}
.form-group{
margin-top: 22px;
label{
color: #999;
font-size: 14px;
font-weight: normal;
}
}
input[type=submit]{
margin: 0 auto;
width: 100%;
}
}
}
3 changes: 2 additions & 1 deletion app/assets/stylesheets/plats/new.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.plat.new{
.new_plat{
.new_plat,.edit_plat{
margin: 0 auto;
border: solid 1px #ddd;
width: 360px;
Expand Down Expand Up @@ -32,6 +32,7 @@
}
input[type=submit]{
margin: 0 auto;
width: 100%;
}
}
}
13 changes: 13 additions & 0 deletions app/assets/stylesheets/plats/show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
padding-left: 0px;
padding-right: 0px;
margin-top: 4px;
&>.nav{
margin-left: 12px;
}
.cell{
overflow: hidden;
$icon_with : 48px;
Expand Down Expand Up @@ -52,6 +55,16 @@
color: #666666;
font-size: 13px;
}
.delete_btn{
margin-top: 2px;
margin-right: $padding_size;
font-size: 12px;
}
@media (max-width: 900px){
.delete_btn{
display: none;
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/scaffolds.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@
color: #463265;
background-color: #fff;
}
}

a,a:hover{
text-decoration: none;
}
16 changes: 15 additions & 1 deletion app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ def new

def create
app = App.create(app_params)
redirect_to app
redirect_to root_path
end

def edit
render 'new'
end

def update
@app.update app_params
redirect_to root_path
end

def destroy
@app.destroy!
redirect_to root_path
end

private
Expand Down
18 changes: 14 additions & 4 deletions app/controllers/pkgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ def new

def create
pkg = Pkg.new(pkg_params)

if @plat.bundle_id.present? && pkg.ident != @plat.bundle_id
raise "Pkg Bundle Id Validation Error"
raise "Pkg Bundle Id Validation Fail"
end

if pkg.plat_name != @plat.plat_name
raise "Pkg Plat Validation Fail"
end

if pkg.plat != @plat.plat
raise "Pkg Plat Validation Error"
if @plat.pkg_uniq? && !pkg.uniq?
raise "Pkg Uniq Validation Fail"
end

pkg.save
Expand All @@ -27,6 +31,12 @@ def create
redirect_to new_plat_pkg_path(@plat), :flash => { :error => e.message }
end

def destroy
pkg = Pkg.find params[:id]
pkg.destroy!
redirect_to app_plat_path pkg.app, pkg.plat
end


private

Expand Down
31 changes: 26 additions & 5 deletions app/controllers/plats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
class PlatsController < ApplicationController
before_action :set_app, only: [:index, :show, :new, :create, :edit, :update, :destroy, :comments]
before_action :set_plat, only: [:show]
before_action :set_app, only: [:index, :show, :new, :create, :destroy]
before_action :set_plat, only: [:show,:destroy,:update,:edit]

def index
@plats = Plat.where(app_id:params[:app_id])
if @plats.present?
redirect_to app_plat_path @app,@plats.first
redirect_to app_plat_path @plats.first.app, @plats.first
else
redirect_to new_app_plat_path @app
end
end

def show
@pkgs = @plat.pkgs
@pkgs = @plat.pkgs.id_desc
@plats = Plat.where(app_id:params[:app_id])
end

Expand All @@ -23,6 +25,25 @@ def create
redirect_to app_plat_path @app, plat
end

def destroy
@plat.destroy!
@plats = Plat.where(app_id:params[:app_id])
if @plats.first
redirect_to app_plat_path @plats.first.app, @plats.first
else
redirect_to new_app_plat_path @app
end
end

def edit
render "new"
end

def update
@plat.update(plat_params)
redirect_to app_plat_path @plat.app, @plat
end

private
# # Use callbacks to share common setup or constraints between actions.
def set_app
Expand All @@ -35,6 +56,6 @@ def set_plat

# # Never trust parameters from the scary internet, only allow the white list through.
def plat_params
params.require(:plat).permit(:name,:app_id,:plat,:bundle_id);
params.require(:plat).permit(:name,:app_id,:plat_name,:bundle_id,:pkg_uniq);
end
end
8 changes: 6 additions & 2 deletions app/models/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

class App < ApplicationRecord

has_many :pkgs
has_many :plats
has_many :pkgs, :dependent => :destroy
has_many :plats, :dependent => :destroy

validates_uniqueness_of :name, :allow_blank => false

def icon
pkgs.last&.icon
end

end
Loading

0 comments on commit 432f7c4

Please sign in to comment.