forked from fixin.me/fixin.me
		
	Merging from main master to my repo master. #4
@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					<svg xmlns="http://www.w3.org/2000/svg" id="icon" viewBox="0 0 24 24"><path d="M12 14L19 7H15V1H9V7H5L12 14M12 11.17L9.83 9H11V3H13V9H14.17L12 11.17M5 16V18H19V16H5M5 22V20H19V22H5Z" /></svg>
 | 
				
			||||||
| 
		 After Width: | Height: | Size: 192 B  | 
@ -15,10 +15,11 @@ class Unit < ApplicationRecord
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  scope :defaults, ->{ where(user: nil) }
 | 
					  scope :defaults, ->{ where(user: nil) }
 | 
				
			||||||
  scope :with_defaults, ->{ self.or(Unit.where(user: nil)) }
 | 
					  scope :with_defaults, ->{ self.or(Unit.where(user: nil)) }
 | 
				
			||||||
  scope :default_diff, ->{
 | 
					  scope :defaults_diff, ->{
 | 
				
			||||||
    other_units = Unit.arel_table.alias('other_units')
 | 
					    other_units = Unit.arel_table.alias('other_units')
 | 
				
			||||||
    other_bases_units = Unit.arel_table.alias('other_bases_units')
 | 
					    other_bases_units = Unit.arel_table.alias('other_bases_units')
 | 
				
			||||||
    constraints = other_bases_units[:id].eq(other_units[:base_id])
 | 
					    constraints = other_bases_units[:id].eq(other_units[:base_id])
 | 
				
			||||||
 | 
					      .and(other_bases_units[:symbol].eq(Arel::Table.new(:bases_units)[:symbol]))
 | 
				
			||||||
      .and(other_units[:symbol].eq(arel_table[:symbol]))
 | 
					      .and(other_units[:symbol].eq(arel_table[:symbol]))
 | 
				
			||||||
      .and(other_units[:user_id].not_eq(arel_table[:user_id]))
 | 
					      .and(other_units[:user_id].not_eq(arel_table[:user_id]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -46,4 +47,8 @@ class Unit < ApplicationRecord
 | 
				
			|||||||
  def movable?
 | 
					  def movable?
 | 
				
			||||||
    subunits.empty?
 | 
					    subunits.empty?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def default?
 | 
				
			||||||
 | 
					    user.nil?
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								app/views/default/units/_unit.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								app/views/default/units/_unit.html.erb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					<%= tag.tr do %>
 | 
				
			||||||
 | 
					  <td class="<%= class_names({subunit: unit.base}) %>">
 | 
				
			||||||
 | 
					    <%= unit.symbol %>
 | 
				
			||||||
 | 
					  </td>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <td class="actions">
 | 
				
			||||||
 | 
					    <% if current_user.at_least(:active) && unit.default? %>
 | 
				
			||||||
 | 
					      <%= image_button_to t(".import"), "download-outline", import_default_unit_path(unit) %>
 | 
				
			||||||
 | 
					    <% end %>
 | 
				
			||||||
 | 
					    <% if current_user.at_least(:admin) %>
 | 
				
			||||||
 | 
					      <% if !unit.default? %>
 | 
				
			||||||
 | 
					        <%= image_button_to t(".export"), "upload-outline", export_default_unit_path(unit) %>
 | 
				
			||||||
 | 
					      <% else %>
 | 
				
			||||||
 | 
					        <%= image_button_to t(".delete"), "delete-outline", unit_path(unit),
 | 
				
			||||||
 | 
					          method: :delete %>
 | 
				
			||||||
 | 
					      <% end %>
 | 
				
			||||||
 | 
					    <% end %>
 | 
				
			||||||
 | 
					  </td>
 | 
				
			||||||
 | 
					<% end %>
 | 
				
			||||||
@ -1,5 +1,9 @@
 | 
				
			|||||||
<div class="rightside buttongrid">
 | 
					<div class="rightside buttongrid">
 | 
				
			||||||
  <%= image_link_to t('.back'), 'arrow-left-bold-outline', units_path %>
 | 
					  <% if current_user.at_least(:active) %>
 | 
				
			||||||
 | 
					    <%= image_link_to t('.import_all'), 'download-multiple-outline',
 | 
				
			||||||
 | 
					      import_all_default_units_path, data: {turbo_stream: true} %>
 | 
				
			||||||
 | 
					  <% end %>
 | 
				
			||||||
 | 
					  <%= image_link_to t('.back'), 'arrow-left-bold-outline', units_path, class: 'tools' %>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<table class="main items">
 | 
					<table class="main items">
 | 
				
			||||||
@ -12,6 +16,6 @@
 | 
				
			|||||||
    </tr>
 | 
					    </tr>
 | 
				
			||||||
  </thead>
 | 
					  </thead>
 | 
				
			||||||
  <tbody id="units">
 | 
					  <tbody id="units">
 | 
				
			||||||
    <%= render(@units, partial: 'default') || render_no_items %>
 | 
					    <%= render(@units) || render_no_items %>
 | 
				
			||||||
  </tbody>
 | 
					  </tbody>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,10 @@ en:
 | 
				
			|||||||
      success: Deleted unit
 | 
					      success: Deleted unit
 | 
				
			||||||
  default:
 | 
					  default:
 | 
				
			||||||
    units:
 | 
					    units:
 | 
				
			||||||
 | 
					      unit:
 | 
				
			||||||
 | 
					        delete_default: Delete default
 | 
				
			||||||
      index:
 | 
					      index:
 | 
				
			||||||
 | 
					        import_all: Import all
 | 
				
			||||||
        back: Back to units...
 | 
					        back: Back to units...
 | 
				
			||||||
  users:
 | 
					  users:
 | 
				
			||||||
    index:
 | 
					    index:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user