From 3370da23973c82a20a5ee4b2e90b1c7223a6d3b8 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Wed, 30 Mar 2022 14:24:20 +0200 Subject: [PATCH] Able to remove popup on click --- src/app.rb | 9 +++++++-- src/db_models.rb | 2 +- src/views/layout.slim | 2 +- src/views/stylesheets/style.sass | 11 +++++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/app.rb b/src/app.rb index 7da1afd..fcafbe8 100755 --- a/src/app.rb +++ b/src/app.rb @@ -173,8 +173,13 @@ post "/auctions" do newid, resp = Auction.create user_id, title, description, init_price, delta_time, category_choices - flash[:success] = "Auction posted!" - redirect "/auctions/#{newid}" + if newid then + flash[:success] = "Auction posted!" + redirect "/auctions/#{newid}" + else + flash[:error] = resp + redirect "/auctions/new" + end end get "/auctions/:id" do diff --git a/src/db_models.rb b/src/db_models.rb index dd9a6f4..8f78e76 100644 --- a/src/db_models.rb +++ b/src/db_models.rb @@ -215,7 +215,7 @@ class Auction < EntityModel # Validate the input check, errorstr = self.validate_ah(title, description, init_price, delta_time) - return errorstr unless check + return check, errorstr unless check # Get current UNIX time start_time = Time.now.to_i diff --git a/src/views/layout.slim b/src/views/layout.slim index b13b664..0749766 100644 --- a/src/views/layout.slim +++ b/src/views/layout.slim @@ -29,7 +29,7 @@ html lang="en" a.inlbutton href="/profile" target="_self" img.avatar src="#{session_user.avatar}" alt="Profile" .content-container - .flash + div class="flash" onclick="this.remove();" - flash.each do |k, v| div class="flash-#{k}" | #{v} diff --git a/src/views/stylesheets/style.sass b/src/views/stylesheets/style.sass index b8bca33..9e58b62 100644 --- a/src/views/stylesheets/style.sass +++ b/src/views/stylesheets/style.sass @@ -142,12 +142,15 @@ a.button:hover background-color: $special_clr .flash - position: absolute + position: fixed text-align: center - top: 5rem + top: 4rem + left: .8rem font-size: 1rem font-weight: bold animation: flash .2s ease-in alternate + background: $bg_alt_clr + transition: .4s opacity &-error color: $fg_error @@ -161,6 +164,10 @@ a.button:hover border: $border_size solid $green_clr border-radius: $border_radius +.flash:hover + cursor: pointer + opacity: .5 + img.avatar, img.avatar_big background: $bg_clr width: 2.25rem