Class: CellsV1::Index::Cell

Inherits:
Cell
  • Object
show all
Defined in:
app/cells/lato_view/cells_v1/index/cell.rb

Overview

Cella Index

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements: nil, head: nil, attributes: nil, link: nil, show_link: true, edit_link: true, delete_link: true, remote_delete: false, custom_class: nil) ⇒ Cell

Returns a new instance of Cell.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 45

def initialize(elements: nil, head: nil, attributes: nil, link: nil,
               show_link: true, edit_link: true, delete_link: true,
               remote_delete: false, custom_class: nil)
  # eseguo brevi controlli sull'input
  raise 'Index Concept: head must be an array' unless head.is_a? Array
  raise 'Index Concept: attributes must be an array' unless attributes.is_a? Array
  raise 'Index Concept: head and attributes have different length' if head.length != attributes.length
  # assegno i valori alle variabili di istanza
  @elements = elements
  @head = head
  @attributes = attributes
  @link = link
  @show_link = show_link
  @edit_link = edit_link
  @delete_link = delete_link
  @remote_delete = remote_delete
  @custom_class = custom_class
end

Instance Attribute Details

#attributesObject

Attributi dellle entita’ da mostrare nella tabella

  • struttura: [‘voce1’, ‘voce2’, … ]



18
19
20
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 18

def attributes
  @attributes
end

#custom_classObject

Valore usato per aggiungere delle classi custom alla tabella dell’index

  • default: nil



43
44
45
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 43

def custom_class
  @custom_class
end

#delete_link=(value) ⇒ Object

Valore booleano che indica se mostrare il link al delete dell’entita’

  • default: true



34
35
36
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 34

def delete_link=(value)
  @delete_link = value
end

#edit_link=(value) ⇒ Object

Valore booleano che indica se mostrare il link all’edit dell’entita’

  • default: true



30
31
32
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 30

def edit_link=(value)
  @edit_link = value
end

#elementsObject

Istanze del database da stampare



10
11
12
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 10

def elements
  @elements
end

#headObject

Funzione che genera l’intestazione dell’index



14
15
16
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 14

def head
  @head
end

Link principale alla pagina index delle entita’ (da gestire tramite resources)



22
23
24
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 22

def link
  @link
end

#remote_deleteObject

Valore booleano che indica se il link di eliminazione deve essere eseguito con il remote: true

  • default: false



39
40
41
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 39

def remote_delete
  @remote_delete
end

#show_link=(value) ⇒ Object

Valore booleano che indica se mostrare il link allo show dell’entita’

  • default: true



26
27
28
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 26

def show_link=(value)
  @show_link = value
end

Instance Method Details

#closeObject

Funzione che stampa la chiusura di una tabella



84
85
86
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 84

def close
  '</table>'
end

#openObject

Funzione che stampa l’apertura dell’index



69
70
71
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 69

def open
  "<table class='table #{@custom_class}'>"
end

#rowsObject

Funzione che stampa le righe dell’index



79
80
81
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 79

def rows
  render 'rows.html'
end

#showObject



64
65
66
# File 'app/cells/lato_view/cells_v1/index/cell.rb', line 64

def show
  open + head + rows + close
end