dorsale 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/javascripts/dorsale/common/forms.coffee +9 -9
- data/app/assets/javascripts/dorsale/engines/alexandrie.coffee +36 -26
- data/app/assets/stylesheets/dorsale/common/upload.sass +16 -13
- data/app/assets/stylesheets/dorsale/engines/alexandrie.sass +40 -0
- data/app/assets/stylesheets/dorsale/engines/billing_machine.sass +1 -1
- data/app/controllers/dorsale/alexandrie/attachments_controller.rb +26 -10
- data/app/models/dorsale/alexandrie/attachment.rb +2 -0
- data/app/models/dorsale/alexandrie/attachment_type.rb +12 -0
- data/app/policies/dorsale/alexandrie/attachment_type_policy_helper.rb +4 -0
- data/app/policies/dorsale/policy_checker.rb +1 -0
- data/app/views/dorsale/alexandrie/attachments/_attachment.html.slim +14 -0
- data/app/views/dorsale/alexandrie/attachments/_edit.html.slim +11 -0
- data/app/views/dorsale/alexandrie/attachments/_header.html.slim +1 -0
- data/app/views/dorsale/alexandrie/attachments/_new.html.slim +17 -0
- data/app/views/dorsale/alexandrie/attachments/_new_disabled.html.slim +23 -0
- data/app/views/dorsale/alexandrie/attachments/_progress_bar.html.slim +9 -0
- data/app/views/dorsale/alexandrie/attachments/index.html.slim +21 -3
- data/app/views/dorsale/billing_machine/invoices/_details.html.slim +1 -3
- data/app/views/dorsale/expense_gun/expenses/show.html.slim +1 -3
- data/config/locales/alexandrie.fr.yml +7 -0
- data/config/locales/common.en.yml +1 -1
- data/config/locales/common.fr.yml +1 -1
- data/db/migrate/20160930073538_create_dorsale_alexandrie_attachment_types.rb +11 -0
- data/features/billing_machine_quotations.feature +0 -3
- data/features/step_definitions/{alexandrie.rb → alexandrie_steps.rb} +6 -1
- data/lib/dorsale/version.rb +1 -1
- data/spec/factories/alexandrie_attachment_types.rb +5 -0
- data/spec/models/dorsale/alexandrie/attachment_spec.rb +2 -0
- data/spec/models/dorsale/alexandrie/attachment_type_spec.rb +11 -0
- metadata +17 -7
- data/app/views/dorsale/alexandrie/attachments/_form.html.slim +0 -26
- data/app/views/dorsale/alexandrie/attachments/_list.html.slim +0 -13
- data/app/views/dorsale/alexandrie/attachments/edit.html.slim +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54b00176fd73832f860580c1b29c2df10ced1e7
|
4
|
+
data.tar.gz: 54b8d3ab4d7c7313ccbc5d7bff8cde201f0923da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08994ede1ad737173a99aead508f6396f7e9641b239250ba4f9ac7a166ccdb569881a1e84df431fb46b907f7bdbc41e0303b5af9b98386300d70a60f601e803b
|
7
|
+
data.tar.gz: afcda582c1ca6f92f428f49b9542e24a9771c93af65aaf69ab0591530f111e52bc72f2fcfdf6f268f2ff5272c097912e323f8ceb6c5b713a3531fa0cbf5a4438
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Fake file input (bootstrap style)
|
1
|
+
# Fake file input (bootstrap style)
|
2
2
|
window.setupUploadInputs = (scope = document) ->
|
3
|
-
$(scope).find(".form-
|
4
|
-
|
5
|
-
form
|
6
|
-
input
|
7
|
-
|
8
|
-
|
9
|
-
progress
|
3
|
+
$(scope).find(".form-control.upload").map ->
|
4
|
+
container = $(this)
|
5
|
+
form = container.parents("form")
|
6
|
+
input = container.find("[type=file]")
|
7
|
+
label = container.find("label")
|
8
|
+
submit = form.find("[type=submit]")
|
9
|
+
progress = form.find(".progress")
|
10
10
|
|
11
11
|
progress.hide() if not xhr2_available()
|
12
12
|
|
@@ -15,7 +15,7 @@ window.setupUploadInputs = (scope = document) ->
|
|
15
15
|
|
16
16
|
input.change ->
|
17
17
|
if this.value == ""
|
18
|
-
submit.prop(disabled: true)
|
18
|
+
submit.prop(disabled: true) if input.hasClass("required")
|
19
19
|
label_value = label.data("defaultValue")
|
20
20
|
else
|
21
21
|
submit.prop(disabled: false)
|
@@ -14,18 +14,46 @@ window.alexandrie =
|
|
14
14
|
success: (data) ->
|
15
15
|
container.html(data)
|
16
16
|
setupUploadInputs(container)
|
17
|
-
alexandrie.
|
18
|
-
alexandrie.setupEditButtons()
|
19
|
-
alexandrie.setupDeleteButtons()
|
17
|
+
alexandrie.setup()
|
20
18
|
|
21
19
|
reload: ->
|
22
20
|
alexandrie.load()
|
23
21
|
|
24
|
-
|
22
|
+
setup: ->
|
23
|
+
alexandrie.setupForms()
|
24
|
+
alexandrie.setupFormsProgress()
|
25
|
+
alexandrie.setupEditButtons()
|
26
|
+
alexandrie.setupDeleteButtons()
|
27
|
+
|
28
|
+
setupForms: ->
|
29
|
+
$("#dorsale-attachments form").on("ajax:success", alexandrie.reload)
|
30
|
+
|
31
|
+
setupEditButtons: ->
|
32
|
+
$("#dorsale-attachments [href$=edit]").click ->
|
33
|
+
container = $("#dorsale-attachments")
|
34
|
+
url = this.href
|
35
|
+
|
36
|
+
$.ajax
|
37
|
+
url: url
|
38
|
+
success: (data) ->
|
39
|
+
container.html(data)
|
40
|
+
setupUploadInputs(container)
|
41
|
+
alexandrie.setup()
|
42
|
+
|
43
|
+
return false
|
44
|
+
|
45
|
+
setupDeleteButtons: ->
|
46
|
+
$("#dorsale-attachments [data-method=delete]").map ->
|
47
|
+
$(this).on("ajax:success", alexandrie.reload)
|
48
|
+
|
49
|
+
setupFormsProgress: ->
|
25
50
|
return unless xhr2_available()
|
26
51
|
return unless alexandrie.enable_xhr_upload
|
27
52
|
|
28
|
-
|
53
|
+
# Ignore progress if no file input
|
54
|
+
return unless $("#dorsale-attachments form input[type=file]").length
|
55
|
+
|
56
|
+
$("#dorsale-attachments form").submit ->
|
29
57
|
form = $(this)
|
30
58
|
xhr = new XMLHttpRequest()
|
31
59
|
data = new FormData(this)
|
@@ -37,7 +65,9 @@ window.alexandrie =
|
|
37
65
|
percentComplete = 1 if percentComplete == 0
|
38
66
|
percentComplete = 99 if percentComplete == 100
|
39
67
|
|
40
|
-
bar
|
68
|
+
# Get edit progress bar if available, new progress bar otherwise
|
69
|
+
bar = $("#edit_attachment_tr + tr .progress-bar").first()
|
70
|
+
bar = $("#new_attachment_tr + tr .progress-bar").first() if bar.length == 0
|
41
71
|
bar.html percentComplete+"%"
|
42
72
|
bar.css "width": percentComplete+"%"
|
43
73
|
bar.attr "aria-valuenow": percentComplete
|
@@ -50,23 +80,3 @@ window.alexandrie =
|
|
50
80
|
xhr.send(data)
|
51
81
|
|
52
82
|
return false
|
53
|
-
|
54
|
-
setupEditForm: ->
|
55
|
-
$("#edit_attachment").on("ajax:success", alexandrie.reload)
|
56
|
-
|
57
|
-
setupEditButtons: ->
|
58
|
-
$("#dorsale-attachments [href$=edit]").click ->
|
59
|
-
container = $(this).parents("li")
|
60
|
-
url = this.href
|
61
|
-
|
62
|
-
$.ajax
|
63
|
-
url: url
|
64
|
-
success: (data) ->
|
65
|
-
container.html(data)
|
66
|
-
alexandrie.setupEditForm()
|
67
|
-
|
68
|
-
return false
|
69
|
-
|
70
|
-
setupDeleteButtons: ->
|
71
|
-
$("#dorsale-attachments [data-method=delete]").map ->
|
72
|
-
$(this).on("ajax:success", alexandrie.reload)
|
@@ -1,21 +1,24 @@
|
|
1
|
-
.form-
|
2
|
-
|
3
|
-
position: relative
|
1
|
+
.form-control.upload
|
2
|
+
position: relative
|
4
3
|
|
5
4
|
input
|
6
5
|
position: absolute
|
7
|
-
|
8
|
-
right: 0
|
9
|
-
bottom: 0
|
10
|
-
left: 0
|
11
|
-
width: 100%
|
6
|
+
display: none
|
12
7
|
opacity: 0
|
13
|
-
z-index:
|
8
|
+
z-index: -9999
|
9
|
+
top: 0px
|
10
|
+
left: -9999px
|
14
11
|
|
15
12
|
label
|
13
|
+
@extend .nostyle
|
16
14
|
position: absolute
|
17
|
-
|
15
|
+
top: 0
|
16
|
+
right: 0
|
17
|
+
bottom: 0
|
18
|
+
left: 0
|
19
|
+
line-height: 2.5em
|
20
|
+
padding: 0 1em
|
18
21
|
font-weight: normal
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
white-space: nowrap
|
23
|
+
overflow: hidden
|
24
|
+
cursor: pointer
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#dorsale-attachments
|
2
|
+
table
|
3
|
+
@extend .table
|
4
|
+
margin: 0
|
5
|
+
|
6
|
+
.attachment-name,
|
7
|
+
.attachment-file,
|
8
|
+
width: 100%
|
9
|
+
|
10
|
+
.attachment-actions
|
11
|
+
white-space: nowrap
|
12
|
+
|
13
|
+
.label
|
14
|
+
@extend .btn-xs
|
15
|
+
letter-spacing: 1px
|
16
|
+
white-space: nowrap
|
17
|
+
display: block
|
18
|
+
text-align: center
|
19
|
+
padding-left: 1rem
|
20
|
+
padding-right: 1rem
|
21
|
+
margin-right: 3rem
|
22
|
+
width: 100%
|
23
|
+
|
24
|
+
table table
|
25
|
+
width: 100%
|
26
|
+
|
27
|
+
#attachment_progress
|
28
|
+
td
|
29
|
+
border: none
|
30
|
+
padding-top: 0
|
31
|
+
padding-bottom: 1em
|
32
|
+
|
33
|
+
.progress
|
34
|
+
margin: 0
|
35
|
+
|
36
|
+
#attachment_attachment_type_id
|
37
|
+
min-width: 12em
|
38
|
+
|
39
|
+
#alexandrie-flash .alert
|
40
|
+
margin: 0
|
@@ -7,11 +7,15 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
7
7
|
:destroy,
|
8
8
|
]
|
9
9
|
|
10
|
+
before_action :set_attachment_types
|
11
|
+
|
10
12
|
def index
|
11
13
|
@attachable = find_attachable
|
12
14
|
skip_policy_scope
|
13
15
|
|
14
16
|
authorize @attachable, :read?
|
17
|
+
|
18
|
+
@attachment = scope.new(attachment_params_for_create)
|
15
19
|
end
|
16
20
|
|
17
21
|
def create
|
@@ -20,7 +24,7 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
20
24
|
authorize @attachment, :create?
|
21
25
|
|
22
26
|
if @attachment.save
|
23
|
-
flash[:notice] = t("messages.attachments.create_ok")
|
27
|
+
# flash[:notice] = t("messages.attachments.create_ok")
|
24
28
|
else
|
25
29
|
flash[:alert] = t("messages.attachments.create_error")
|
26
30
|
end
|
@@ -30,13 +34,17 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
30
34
|
|
31
35
|
def edit
|
32
36
|
authorize @attachment, :update?
|
37
|
+
|
38
|
+
@attachable = @attachment.attachable
|
39
|
+
|
40
|
+
render :index
|
33
41
|
end
|
34
42
|
|
35
43
|
def update
|
36
44
|
authorize @attachment, :update?
|
37
45
|
|
38
46
|
if @attachment.update(attachment_params_for_update)
|
39
|
-
flash[:notice] = t("messages.attachments.update_ok")
|
47
|
+
# flash[:notice] = t("messages.attachments.update_ok")
|
40
48
|
else
|
41
49
|
flash[:alert] = t("messages.attachments.update_error")
|
42
50
|
end
|
@@ -48,7 +56,7 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
48
56
|
authorize @attachment, :delete?
|
49
57
|
|
50
58
|
if @attachment.destroy
|
51
|
-
flash[:notice] = t("messages.attachments.delete_ok")
|
59
|
+
# flash[:notice] = t("messages.attachments.delete_ok")
|
52
60
|
else
|
53
61
|
flash[:alert] = t("messages.attachments.delete_error")
|
54
62
|
end
|
@@ -70,6 +78,10 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
70
78
|
@attachment = scope.find(params[:id])
|
71
79
|
end
|
72
80
|
|
81
|
+
def set_attachment_types
|
82
|
+
@attachment_types = policy_scope(::Dorsale::Alexandrie::AttachmentType).all
|
83
|
+
end
|
84
|
+
|
73
85
|
def attachable_type
|
74
86
|
params[:attachable_type] || @attachment.attachable_type
|
75
87
|
end
|
@@ -84,31 +96,35 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
|
|
84
96
|
raise ActiveRecord::RecordNotFound
|
85
97
|
end
|
86
98
|
|
87
|
-
def
|
99
|
+
def common_permitted_params
|
88
100
|
[
|
101
|
+
:name,
|
102
|
+
:attachment_type_id
|
103
|
+
]
|
104
|
+
end
|
105
|
+
|
106
|
+
def permitted_params_for_create
|
107
|
+
common_permitted_params + [
|
89
108
|
:attachable_id,
|
90
109
|
:attachable_type,
|
91
110
|
:file,
|
92
|
-
:name
|
93
111
|
]
|
94
112
|
end
|
95
113
|
|
96
114
|
def attachment_params_for_create
|
97
115
|
params
|
98
|
-
.
|
116
|
+
.fetch(:attachment, {})
|
99
117
|
.permit(permitted_params_for_create)
|
100
118
|
.merge(sender: current_user)
|
101
119
|
end
|
102
120
|
|
103
121
|
def permitted_params_for_update
|
104
|
-
|
105
|
-
:name,
|
106
|
-
]
|
122
|
+
common_permitted_params
|
107
123
|
end
|
108
124
|
|
109
125
|
def attachment_params_for_update
|
110
126
|
params
|
111
|
-
.
|
127
|
+
.fetch(:attachment, {})
|
112
128
|
.permit(permitted_params_for_update)
|
113
129
|
end
|
114
130
|
|
@@ -4,6 +4,8 @@ class Dorsale::Alexandrie::Attachment < ActiveRecord::Base
|
|
4
4
|
belongs_to :attachable, polymorphic: true
|
5
5
|
belongs_to :sender, polymorphic: true
|
6
6
|
|
7
|
+
belongs_to :attachment_type, required: false
|
8
|
+
|
7
9
|
validates :attachable, presence: true
|
8
10
|
validates :file, presence: true
|
9
11
|
|
@@ -7,6 +7,7 @@ class Dorsale::PolicyChecker
|
|
7
7
|
errors.clear
|
8
8
|
|
9
9
|
check_policy! "Dorsale::Alexandrie::AttachmentPolicy"
|
10
|
+
check_policy! "Dorsale::Alexandrie::AttachmentTypePolicy"
|
10
11
|
check_policy! "Dorsale::BillingMachine::IdCardPolicy"
|
11
12
|
check_policy! "Dorsale::BillingMachine::InvoicePolicy"
|
12
13
|
check_policy! "Dorsale::BillingMachine::PaymentTermPolicy"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
tr.attachment
|
2
|
+
td.attachment-name
|
3
|
+
= link_to attachment, attachment.file.url, download: attachment.download_filename
|
4
|
+
|
5
|
+
td.attachment-attachment_type.hidden-xs.hidden-sm
|
6
|
+
- if attachment.attachment_type
|
7
|
+
.label.label-info = attachment.attachment_type
|
8
|
+
|
9
|
+
td.attachment-actions
|
10
|
+
- if policy(attachment).update?
|
11
|
+
= update_button dorsale.edit_alexandrie_attachment_path(attachment)
|
12
|
+
|
13
|
+
- if policy(attachment).delete?
|
14
|
+
= delete_button dorsale.alexandrie_attachment_path(attachment), remote: true
|
@@ -0,0 +1,11 @@
|
|
1
|
+
tr#edit_attachment_tr
|
2
|
+
td.attachment-name
|
3
|
+
= text_field :attachment, :name, class: "form-control input-sm"
|
4
|
+
|
5
|
+
td.attachment-attachment_type.hidden-xs.hidden-sm
|
6
|
+
- if @attachment_types.to_a.any?
|
7
|
+
= collection_select :attachment, :attachment_type_id, @attachment_types, :id, :to_s, {include_blank: true}, {class: "form-control input-sm"}
|
8
|
+
|
9
|
+
td.attachment-actions
|
10
|
+
button.btn.btn-success.btn-sm.btn-block type="submit"
|
11
|
+
= t("actions.save")
|
@@ -0,0 +1 @@
|
|
1
|
+
/ This file is used to add headers on host applications
|
@@ -0,0 +1,17 @@
|
|
1
|
+
tr#new_attachment_tr
|
2
|
+
td.attachment-file
|
3
|
+
.form-control.input-sm.upload
|
4
|
+
= file_field :attachment, :file, {class: "required"}
|
5
|
+
label for="attachment_file" = t("actions.browse")
|
6
|
+
|
7
|
+
td.attachment-attachment_type.hidden-xs.hidden-sm
|
8
|
+
- if @attachment_types.to_a.any?
|
9
|
+
= collection_select :attachment, :attachment_type_id, @attachment_types, :id, :to_s, {include_blank: true}, {class: "form-control input-sm"}
|
10
|
+
|
11
|
+
td.attachment-actions
|
12
|
+
= hidden_field :attachment, :attachable_id, value: attachable.id.to_s
|
13
|
+
= hidden_field :attachment, :attachable_type, value: attachable.class.to_s
|
14
|
+
button.btn.btn-success.btn-sm.btn-block type="submit"
|
15
|
+
= t("actions.upload")
|
16
|
+
|
17
|
+
= render "dorsale/alexandrie/attachments/progress_bar"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
tr#new_attachment_tr
|
2
|
+
td.attachment-file
|
3
|
+
input(
|
4
|
+
value = t("actions.browse")
|
5
|
+
disabled = "disabled"
|
6
|
+
class = "form-control input-sm"
|
7
|
+
)
|
8
|
+
|
9
|
+
td.attachment-attachment_type.hidden-xs.hidden-sm
|
10
|
+
select(
|
11
|
+
disabled = "disabled"
|
12
|
+
class = "form-control input-sm"
|
13
|
+
)
|
14
|
+
|
15
|
+
td.attachment-actions
|
16
|
+
button(
|
17
|
+
class = "btn btn-success btn-sm btn-block"
|
18
|
+
type = "button"
|
19
|
+
disabled = "disabled"
|
20
|
+
)
|
21
|
+
= t("actions.upload")
|
22
|
+
|
23
|
+
= render "dorsale/alexandrie/attachments/progress_bar"
|
@@ -1,6 +1,24 @@
|
|
1
1
|
= render "dorsale/flash"
|
2
2
|
|
3
|
-
-
|
4
|
-
|
3
|
+
.panel.panel-default
|
4
|
+
.panel-heading: .panel-title = ::Dorsale::Alexandrie::Attachment.ts
|
5
5
|
|
6
|
-
=
|
6
|
+
= form_for(@attachment, as: :attachment, remote: true) do |f|
|
7
|
+
= hidden_field_tag :authenticity_token, form_authenticity_token
|
8
|
+
|
9
|
+
table
|
10
|
+
= render "dorsale/alexandrie/attachments/header"
|
11
|
+
|
12
|
+
tbody
|
13
|
+
- if policy(::Dorsale::Alexandrie::Attachment).create?
|
14
|
+
/ Create only on index
|
15
|
+
- if params[:action] == "index"
|
16
|
+
= render "dorsale/alexandrie/attachments/new", attachable: @attachable
|
17
|
+
- else
|
18
|
+
= render "dorsale/alexandrie/attachments/new_disabled"
|
19
|
+
|
20
|
+
- ::Dorsale::Alexandrie::Attachment.where(attachable: @attachable).each do |attachment|
|
21
|
+
- if request.path == url_for(action: :edit, id: attachment)
|
22
|
+
= render "dorsale/alexandrie/attachments/edit", attachment: attachment
|
23
|
+
- else
|
24
|
+
= render "dorsale/alexandrie/attachments/attachment", attachment: attachment
|
@@ -21,8 +21,15 @@ fr:
|
|
21
21
|
create_ok : "La Paiement a été créé."
|
22
22
|
update_ok : "La Paiement a été modifié."
|
23
23
|
|
24
|
+
attributes:
|
25
|
+
attachment_type: "Type de document"
|
26
|
+
|
24
27
|
activerecord:
|
25
28
|
models:
|
26
29
|
dorsale/alexandrie/attachment:
|
27
30
|
one: "Document"
|
28
31
|
other: "Documents"
|
32
|
+
|
33
|
+
dorsale/alexandrie/attachment_type:
|
34
|
+
one: "Type de document"
|
35
|
+
other: "Types de document"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateDorsaleAlexandrieAttachmentTypes < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :dorsale_alexandrie_attachment_types do |t|
|
4
|
+
t.string :name
|
5
|
+
t.timestamps null: false
|
6
|
+
end
|
7
|
+
|
8
|
+
add_column :dorsale_alexandrie_attachments, :attachment_type_id, :integer
|
9
|
+
add_index :dorsale_alexandrie_attachments, :attachment_type_id
|
10
|
+
end
|
11
|
+
end
|
@@ -134,21 +134,18 @@ Feature: Quotation Management
|
|
134
134
|
And 2 associated documents to this quotation
|
135
135
|
When the user goes to the quotation details
|
136
136
|
And he delete a document
|
137
|
-
Then a message signals the success of the quotation update
|
138
137
|
And the document is not in the quotation details
|
139
138
|
|
140
139
|
Scenario: Create a document
|
141
140
|
And an existing quotation
|
142
141
|
When the user goes to the quotation details
|
143
142
|
And he add a new document
|
144
|
-
Then a message signals the success of the quotation update
|
145
143
|
And the document is in the quotation details
|
146
144
|
|
147
145
|
Scenario: Update a document
|
148
146
|
And an existing quotation
|
149
147
|
When the user goes to the quotation details
|
150
148
|
And he add a new document
|
151
|
-
Then a message signals the success of the quotation update
|
152
149
|
And the document is in the quotation details
|
153
150
|
When he update the document
|
154
151
|
Then the document is updated
|
@@ -1,6 +1,11 @@
|
|
1
1
|
When(/^he add a new document$/) do
|
2
|
+
execute_script %(
|
3
|
+
$("[type=file]").show()
|
4
|
+
)
|
5
|
+
|
2
6
|
attach_file :attachment_file, Dorsale::Engine.root.join("spec/files/pdf.pdf"), visible: :all
|
3
|
-
|
7
|
+
|
8
|
+
find("#new_attachment [type=submit]").click
|
4
9
|
end
|
5
10
|
|
6
11
|
When(/^he delete a document$/) do
|
data/lib/dorsale/version.rb
CHANGED
@@ -3,10 +3,12 @@ require "rails_helper"
|
|
3
3
|
describe ::Dorsale::Alexandrie::Attachment, type: :model do
|
4
4
|
it { is_expected.to belong_to :attachable }
|
5
5
|
it { is_expected.to belong_to :sender }
|
6
|
+
it { is_expected.to belong_to :attachment_type }
|
6
7
|
|
7
8
|
it { is_expected.to validate_presence_of :attachable }
|
8
9
|
it { is_expected.to validate_presence_of :file }
|
9
10
|
|
11
|
+
it { is_expected.to_not validate_presence_of :attachment_type }
|
10
12
|
it { is_expected.to_not validate_presence_of :sender }
|
11
13
|
|
12
14
|
it "factory should be valid" do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
describe ::Dorsale::Alexandrie::AttachmentType, type: :model do
|
4
|
+
it { is_expected.to have_many(:attachments).dependent(:nullify) }
|
5
|
+
|
6
|
+
it { is_expected.to validate_presence_of :name }
|
7
|
+
|
8
|
+
it "factory should be valid" do
|
9
|
+
expect(create(:alexandrie_attachment_type)).to be_valid
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorsale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -549,6 +549,7 @@ files:
|
|
549
549
|
- app/models/dorsale/address.rb
|
550
550
|
- app/models/dorsale/alexandrie.rb
|
551
551
|
- app/models/dorsale/alexandrie/attachment.rb
|
552
|
+
- app/models/dorsale/alexandrie/attachment_type.rb
|
552
553
|
- app/models/dorsale/billing_machine.rb
|
553
554
|
- app/models/dorsale/billing_machine/id_card.rb
|
554
555
|
- app/models/dorsale/billing_machine/invoice.rb
|
@@ -603,6 +604,7 @@ files:
|
|
603
604
|
- app/pdfs/dorsale/billing_machine/quotation_single_vat_pdf.rb
|
604
605
|
- app/pdfs/dorsale/flyboy/roadmap.rb
|
605
606
|
- app/policies/dorsale/alexandrie/attachment_policy_helper.rb
|
607
|
+
- app/policies/dorsale/alexandrie/attachment_type_policy_helper.rb
|
606
608
|
- app/policies/dorsale/application_policy.rb
|
607
609
|
- app/policies/dorsale/billing_machine/id_card_policy_helper.rb
|
608
610
|
- app/policies/dorsale/billing_machine/invoice_policy_helper.rb
|
@@ -635,10 +637,13 @@ files:
|
|
635
637
|
- app/views/dorsale/_contextual.html.slim
|
636
638
|
- app/views/dorsale/_flash.html.slim
|
637
639
|
- app/views/dorsale/_index.html.slim
|
638
|
-
- app/views/dorsale/alexandrie/attachments/
|
639
|
-
- app/views/dorsale/alexandrie/attachments/
|
640
|
+
- app/views/dorsale/alexandrie/attachments/_attachment.html.slim
|
641
|
+
- app/views/dorsale/alexandrie/attachments/_edit.html.slim
|
642
|
+
- app/views/dorsale/alexandrie/attachments/_header.html.slim
|
640
643
|
- app/views/dorsale/alexandrie/attachments/_loader.html.slim
|
641
|
-
- app/views/dorsale/alexandrie/attachments/
|
644
|
+
- app/views/dorsale/alexandrie/attachments/_new.html.slim
|
645
|
+
- app/views/dorsale/alexandrie/attachments/_new_disabled.html.slim
|
646
|
+
- app/views/dorsale/alexandrie/attachments/_progress_bar.html.slim
|
642
647
|
- app/views/dorsale/alexandrie/attachments/index.html.slim
|
643
648
|
- app/views/dorsale/billing_machine/id_cards/_form.html.slim
|
644
649
|
- app/views/dorsale/billing_machine/id_cards/_list.html.slim
|
@@ -800,6 +805,7 @@ files:
|
|
800
805
|
- db/migrate/20160125201025_create_expense_gun.rb
|
801
806
|
- db/migrate/20160317124838_add_user_on_expense_gun_expense.rb
|
802
807
|
- db/migrate/20160910164840_create_dorsale_customer_vault_people.rb
|
808
|
+
- db/migrate/20160930073538_create_dorsale_alexandrie_attachment_types.rb
|
803
809
|
- features/access.feature
|
804
810
|
- features/billing_machine_id_cards.feature
|
805
811
|
- features/billing_machine_invoices.feature
|
@@ -820,7 +826,7 @@ files:
|
|
820
826
|
- features/flyboy_tasks.feature
|
821
827
|
- features/flyboy_tasks_summary.feature
|
822
828
|
- features/step_definitions/access_steps.rb
|
823
|
-
- features/step_definitions/
|
829
|
+
- features/step_definitions/alexandrie_steps.rb
|
824
830
|
- features/step_definitions/billing_machine_id_cards_steps.rb
|
825
831
|
- features/step_definitions/billing_machine_invoices_steps.rb
|
826
832
|
- features/step_definitions/billing_machine_multiple_vat.rb
|
@@ -879,6 +885,7 @@ files:
|
|
879
885
|
- spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
|
880
886
|
- spec/controllers/dorsale/flyboy/tasks_controller_spec.rb
|
881
887
|
- spec/controllers/dorsale/small_data/filters_controller_spec.rb
|
888
|
+
- spec/factories/alexandrie_attachment_types.rb
|
882
889
|
- spec/factories/alexandrie_attachments.rb
|
883
890
|
- spec/factories/billing_machine_id_cards.rb
|
884
891
|
- spec/factories/billing_machine_invoice_lines.rb
|
@@ -908,6 +915,7 @@ files:
|
|
908
915
|
- spec/mailers/user_mailer.rb
|
909
916
|
- spec/models/dorsale/address_spec.rb
|
910
917
|
- spec/models/dorsale/alexandrie/attachment_spec.rb
|
918
|
+
- spec/models/dorsale/alexandrie/attachment_type_spec.rb
|
911
919
|
- spec/models/dorsale/billing_machine/id_card_spec.rb
|
912
920
|
- spec/models/dorsale/billing_machine/invoice_line_spec.rb
|
913
921
|
- spec/models/dorsale/billing_machine/invoice_spec.rb
|
@@ -987,6 +995,7 @@ test_files:
|
|
987
995
|
- spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
|
988
996
|
- spec/controllers/dorsale/flyboy/tasks_controller_spec.rb
|
989
997
|
- spec/controllers/dorsale/small_data/filters_controller_spec.rb
|
998
|
+
- spec/factories/alexandrie_attachment_types.rb
|
990
999
|
- spec/factories/alexandrie_attachments.rb
|
991
1000
|
- spec/factories/billing_machine_id_cards.rb
|
992
1001
|
- spec/factories/billing_machine_invoice_lines.rb
|
@@ -1016,6 +1025,7 @@ test_files:
|
|
1016
1025
|
- spec/mailers/user_mailer.rb
|
1017
1026
|
- spec/models/dorsale/address_spec.rb
|
1018
1027
|
- spec/models/dorsale/alexandrie/attachment_spec.rb
|
1028
|
+
- spec/models/dorsale/alexandrie/attachment_type_spec.rb
|
1019
1029
|
- spec/models/dorsale/billing_machine/id_card_spec.rb
|
1020
1030
|
- spec/models/dorsale/billing_machine/invoice_line_spec.rb
|
1021
1031
|
- spec/models/dorsale/billing_machine/invoice_spec.rb
|
@@ -1081,7 +1091,7 @@ test_files:
|
|
1081
1091
|
- features/flyboy_tasks.feature
|
1082
1092
|
- features/flyboy_tasks_summary.feature
|
1083
1093
|
- features/step_definitions/access_steps.rb
|
1084
|
-
- features/step_definitions/
|
1094
|
+
- features/step_definitions/alexandrie_steps.rb
|
1085
1095
|
- features/step_definitions/billing_machine_id_cards_steps.rb
|
1086
1096
|
- features/step_definitions/billing_machine_invoices_steps.rb
|
1087
1097
|
- features/step_definitions/billing_machine_multiple_vat.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
= simple_form_for([dorsale, Dorsale::Alexandrie::Attachment.new],
|
2
|
-
:as => :attachment,
|
3
|
-
:multipart => true,
|
4
|
-
) do |f|
|
5
|
-
|
6
|
-
= f.hidden_field :attachable_id, value: attachable.id.to_s
|
7
|
-
= f.hidden_field :attachable_type, value: attachable.class.to_s
|
8
|
-
|
9
|
-
.form-group.upload
|
10
|
-
.input-group
|
11
|
-
.form-control
|
12
|
-
= f.file_field :file
|
13
|
-
label.nostyle = t("actions.browse")
|
14
|
-
|
15
|
-
span.input-group-btn
|
16
|
-
button.btn.btn-success type="submit"
|
17
|
-
= t("actions.upload")
|
18
|
-
|
19
|
-
.progress
|
20
|
-
.progress-bar(
|
21
|
-
style="width: 0%"
|
22
|
-
role="progressbar"
|
23
|
-
aria-valuenow=0
|
24
|
-
aria-valuemin=0
|
25
|
-
aria-valuemax=100
|
26
|
-
) = percentage(0)
|
@@ -1,13 +0,0 @@
|
|
1
|
-
ul.list-group.attachments
|
2
|
-
- ::Dorsale::Alexandrie::Attachment.where(attachable: attachable).each do |a|
|
3
|
-
li.list-group-item.attachment
|
4
|
-
= link_to a, a.file.url, download: a.download_filename
|
5
|
-
|
6
|
-
.pull-right
|
7
|
-
- if policy(a).update?
|
8
|
-
= update_button dorsale.edit_alexandrie_attachment_path(a), action: :rename
|
9
|
-
|
10
|
-
= " "
|
11
|
-
|
12
|
-
- if policy(a).delete?
|
13
|
-
= delete_button dorsale.alexandrie_attachment_path(a), remote: true
|