40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/uploadbox/engine.rb', line 40
def uploads_one(upload_name, options={})
upload_model_class = "Uploadbox::#{@object.class.base_class.to_s + upload_name.to_s.camelize}".constantize
if upload_model_class.versions.present?
options.reverse_merge!(preview: upload_model_class.versions.keys.first,
namespace: false,
default: false,
update_label: 'Alterar',
choose_label: 'Escolher',
destroy_label: '×'.html_safe)
dimensions = upload_model_class.versions[options[:preview]]
@template.render partial: 'uploadbox/images/uploads_one', locals: {
upload_name: upload_name,
resource: @object,
form: self,
version: options[:preview],
width: dimensions[0],
height: dimensions[1],
namespace: options[:namespace],
default: options[:default],
removable: upload_model_class.removable?,
update_label: options[:update_label],
choose_label: options[:choose_label],
destroy_label: options[:destroy_label]
}
else
options.reverse_merge!(namespace: false,
default: false,
update_label: 'Alterar',
choose_label: 'Escolher',
destroy_label: '×'.html_safe)
dimensions = upload_model_class.versions[options[:preview]]
@template.render partial: 'uploadbox/files/uploads_one', locals: {
upload_name: upload_name,
resource: @object,
form: self,
namespace: options[:namespace],
removable: upload_model_class.removable?,
update_label: options[:update_label],
choose_label: options[:choose_label],
destroy_label: options[:destroy_label]
}
end
end
|