From 11dfd8dbb2290ec8a0864dd9a8a7ade90c564476 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 5 Feb 2018 12:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=88=E5=A2=9E=E5=88=A0=E6=9F=A5=E6=94=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/statistics.js.coffee | 3 + app/assets/stylesheets/scaffolds.css.scss | 69 + app/assets/stylesheets/statistics.css.scss | 3 + app/controllers/statistics_controller.rb | 83 + app/helpers/statistics_helper.rb | 2 + app/models/statistic.rb | 3 + app/views/layouts/_logined_header.html.erb | 3 + app/views/statistics/_form.html.erb | 33 + app/views/statistics/edit.html.erb | 6 + app/views/statistics/index.html.erb | 29 + app/views/statistics/new.html.erb | 5 + app/views/statistics/show.html.erb | 25 + config/routes.rb | 3225 +++++++++-------- .../20180205031602_create_statistics.rb | 12 + db/schema.rb | 620 +++- 15 files changed, 2415 insertions(+), 1706 deletions(-) create mode 100644 app/assets/javascripts/statistics.js.coffee create mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/assets/stylesheets/statistics.css.scss create mode 100644 app/controllers/statistics_controller.rb create mode 100644 app/helpers/statistics_helper.rb create mode 100644 app/models/statistic.rb create mode 100644 app/views/statistics/_form.html.erb create mode 100644 app/views/statistics/edit.html.erb create mode 100644 app/views/statistics/index.html.erb create mode 100644 app/views/statistics/new.html.erb create mode 100644 app/views/statistics/show.html.erb create mode 100644 db/migrate/20180205031602_create_statistics.rb diff --git a/app/assets/javascripts/statistics.js.coffee b/app/assets/javascripts/statistics.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/statistics.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 000000000..6ec6a8ff5 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +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: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/assets/stylesheets/statistics.css.scss b/app/assets/stylesheets/statistics.css.scss new file mode 100644 index 000000000..8ccb96220 --- /dev/null +++ b/app/assets/stylesheets/statistics.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the statistics controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb new file mode 100644 index 000000000..1d22bd5eb --- /dev/null +++ b/app/controllers/statistics_controller.rb @@ -0,0 +1,83 @@ +class StatisticsController < ApplicationController + # GET /statistics + # GET /statistics.json + def index + @statistics = Statistic.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @statistics } + end + end + + # GET /statistics/1 + # GET /statistics/1.json + def show + @statistic = Statistic.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @statistic } + end + end + + # GET /statistics/new + # GET /statistics/new.json + def new + @statistic = Statistic.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @statistic } + end + end + + # GET /statistics/1/edit + def edit + @statistic = Statistic.find(params[:id]) + end + + # POST /statistics + # POST /statistics.json + def create + @statistic = Statistic.new(params[:statistic]) + + respond_to do |format| + if @statistic.save + format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' } + format.json { render json: @statistic, status: :created, location: @statistic } + else + format.html { render action: "new" } + format.json { render json: @statistic.errors, status: :unprocessable_entity } + end + end + end + + # PUT /statistics/1 + # PUT /statistics/1.json + def update + @statistic = Statistic.find(params[:id]) + + respond_to do |format| + if @statistic.update_attributes(params[:statistic]) + format.html { redirect_to @statistic, notice: 'Statistic was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @statistic.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /statistics/1 + # DELETE /statistics/1.json + def destroy + @statistic = Statistic.find(params[:id]) + @statistic.destroy + + respond_to do |format| + format.html { redirect_to statistics_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/statistics_helper.rb b/app/helpers/statistics_helper.rb new file mode 100644 index 000000000..2d25d41c5 --- /dev/null +++ b/app/helpers/statistics_helper.rb @@ -0,0 +1,2 @@ +module StatisticsHelper +end diff --git a/app/models/statistic.rb b/app/models/statistic.rb new file mode 100644 index 000000000..b3f6d00e7 --- /dev/null +++ b/app/models/statistic.rb @@ -0,0 +1,3 @@ +class Statistic < ActiveRecord::Base + attr_accessible :description, :name, :status, :user_id +end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 6d9ad618f..60049f5a8 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -22,6 +22,9 @@ + <% if hidden_unproject_infos %>