copycat 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -393,6 +393,13 @@ div.edit {
393
393
  width: 99%;
394
394
  }
395
395
 
396
+ div.edit h2 {
397
+ float: left;
398
+ max-width: 75%;
399
+ overflow: hidden;
400
+ text-overflow: ellipsis;
401
+ }
402
+
396
403
  div.edit textarea {
397
404
  width: 99%;
398
405
  margin-top: 1em;
@@ -400,7 +407,14 @@ div.edit textarea {
400
407
 
401
408
  div.edit a {
402
409
  display: block;
403
- margin: -2em 0 0 .5em;
410
+ margin: 0 0 0 .5em;
411
+ }
412
+
413
+ div.edit form {
414
+ margin-bottom: 0px;
415
+ }
416
+ div.edit form.button_to {
417
+ float: right;
404
418
  }
405
419
 
406
420
  body {
@@ -441,7 +455,9 @@ body {
441
455
 
442
456
  #notice {
443
457
  height: 2em;
444
- background-color: #FFFFBB;
458
+ background-color: #FFD;
445
459
  text-align: center;
460
+ padding-top: .5em;
461
+ margin-bottom: .5em;
446
462
  }
447
463
 
@@ -22,21 +22,14 @@ class CopycatTranslationsController < ActionController::Base
22
22
  end
23
23
 
24
24
  def edit
25
- @copycat_translation = CopycatTranslation.find_by_id(params["id"])
25
+ @copycat_translation = CopycatTranslation.find(params[:id])
26
26
  end
27
27
 
28
28
  def update
29
- cct = CopycatTranslation.find_by_id(params["id"])
30
- cct.value = params["copycat_translation"]["value"]
31
- if cct.save
32
- redirect_to copycat_translations_path
33
- else
34
- @copycat_translation = cct
35
- render :action => 'edit'
36
- end
37
- end
38
-
39
- def help
29
+ @copycat_translation = CopycatTranslation.find(params[:id])
30
+ @copycat_translation.value = params[:copycat_translation][:value]
31
+ @copycat_translation.save!
32
+ redirect_to copycat_translations_path, :notice => "#{@copycat_translation.key} updated!"
40
33
  end
41
34
 
42
35
  def import_export
@@ -51,6 +44,7 @@ class CopycatTranslationsController < ActionController::Base
51
44
  begin
52
45
  CopycatTranslation.import_yaml(params["file"].tempfile)
53
46
  rescue StandardError => e
47
+ logger.info "\n#{e.class}\n#{e.message}"
54
48
  flash[:notice] = "There was an error processing your upload!"
55
49
  render :action => 'import_export', :status => 400
56
50
  else
@@ -58,4 +52,13 @@ class CopycatTranslationsController < ActionController::Base
58
52
  end
59
53
  end
60
54
 
55
+ def destroy
56
+ @copycat_translation = CopycatTranslation.find(params[:id])
57
+ notice = "#{@copycat_translation.key} deleted!"
58
+ @copycat_translation.destroy
59
+ redirect_to copycat_translations_path, :notice => notice
60
+ end
61
+
62
+ def help
63
+ end
61
64
  end
@@ -1,10 +1,9 @@
1
1
  <div class="edit">
2
- <%= form_for @copycat_translation, :url => { :action => "update" }, :html => {:class => "copycat_translation"} do |f| %>
3
- <span class="copycat-edit-form-key"><%= @copycat_translation.key %></span>
4
- <br>
5
- <%= f.text_area :value, :size => "60x12" %>
6
- <br>
7
- <%= f.submit "Update" %>
8
- <% end %>
9
- <%= link_to "Cancel", copycat_translations_path %>
2
+ <h2><%= @copycat_translation.key%></h2>
3
+ <%= button_to "Delete this item", copycat_translation_path(@copycat_translation), :method => :delete, :onclick => "return confirm('Are you sure?');" %>
4
+ <%= form_for @copycat_translation, :url => { :action => "update" } do |f| %>
5
+ <%= f.text_area :value, :rows => 12 %>
6
+ <%= f.submit "Update" %>
7
+ <% end %>
8
+ <%= link_to "Cancel", copycat_translations_path %>
10
9
  </div>
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- resources :copycat_translations, :only => [:index, :edit, :update] do
2
+ resources :copycat_translations, :only => [:index, :edit, :update, :destroy] do
3
3
  collection do
4
4
  get 'help'
5
5
  get 'import_export'
@@ -1,3 +1,3 @@
1
1
  module Copycat
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
Binary file