Skip to content

Commit cabfe45

Browse files
authored
Merge from docusealco/wip
2 parents da44d51 + 4ade6a5 commit cabfe45

23 files changed

Lines changed: 169 additions & 58 deletions

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ GEM
271271
rdoc (>= 4.0.0)
272272
reline (>= 0.4.2)
273273
jmespath (1.6.2)
274-
json (2.19.8)
274+
json (2.19.9)
275275
jwt (3.2.0)
276276
base64
277277
language_server-protocol (3.17.0.5)

app/controllers/preview_document_page_controller.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def show
2525
preview_image = attachment.preview_images.joins(:blob)
2626
.find_by(blob: { filename: ["#{params[:id]}.png", "#{params[:id]}.jpg"] })
2727

28-
return redirect_to preview_image.url, allow_other_host: true if preview_image
28+
if preview_image
29+
return redirect_to preview_image.url(time: ActiveStorage::Attachment.service_url_time),
30+
allow_other_host: true
31+
end
2932

3033
file_path =
3134
if attachment.service.name == :disk
@@ -37,7 +40,7 @@ def show
3740
preview_image =
3841
Templates::ProcessDocument.generate_pdf_preview_from_file(attachment, file_path, params[:id].to_i)
3942

40-
redirect_to preview_image.url, allow_other_host: true
43+
redirect_to preview_image.url(time: ActiveStorage::Attachment.service_url_time), allow_other_host: true
4144
end
4245

4346
def find_or_create_document_tempfile_path(attachment)

app/controllers/start_form_controller.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,16 @@ def load_resubmit_submitter
108108
end
109109

110110
def can_resubmit?(submitter)
111-
submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false
111+
submitter.completed_at? && submitter.completed_at > 14.days.ago &&
112+
%w[api embed mcp].exclude?(submitter.submission.source) &&
113+
submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false
112114
end
113115

114116
def authorize_start!
115-
return redirect_to submit_form_path(@resubmit_submitter.slug) if @resubmit_submitter && @template.archived_at?
116-
return redirect_to start_form_path(@template.slug) if @template.archived_at?
117+
is_archived = @template.archived_at? || @template.account.archived_at?
118+
119+
return redirect_to submit_form_path(@resubmit_submitter.slug) if @resubmit_submitter && is_archived
120+
return redirect_to start_form_path(@template.slug) if is_archived
117121

118122
return if @resubmit_submitter
119123
return if @template.shared_link? || (current_user && current_ability.can?(:read, @template))

app/controllers/submit_form_decline_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class SubmitFormDeclineController < ApplicationController
77
before_action :load_submitter
88

99
def create
10-
return redirect_to submit_form_path(@submitter.slug) if @submitter.declined_at? ||
10+
return redirect_to submit_form_path(@submitter.slug) if declining_disabled? ||
11+
@submitter.declined_at? ||
1112
@submitter.completed_at? ||
1213
@submitter.submission.archived_at? ||
1314
@submitter.submission.expired? ||
@@ -35,6 +36,10 @@ def create
3536

3637
private
3738

39+
def declining_disabled?
40+
@submitter.account.account_configs.find_by(key: AccountConfig::ALLOW_TO_DECLINE_KEY)&.value == false
41+
end
42+
3843
def load_submitter
3944
@submitter = Submitter.find_by!(slug: params[:submit_form_slug])
4045
end

app/controllers/submitters_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def edit
1313
def update
1414
submission = @submitter.submission
1515

16-
if @submitter.submission_events.exists?(event_type: 'start_form') || submission.archived_at? || submission.expired?
16+
unless submitter_editable?(submission)
1717
return redirect_back fallback_location: submission_path(submission), alert: I18n.t('submitter_cannot_be_updated')
1818
end
1919

@@ -48,6 +48,12 @@ def update
4848

4949
private
5050

51+
def submitter_editable?(submission)
52+
!@submitter.submission_events.exists?(event_type: 'start_form') &&
53+
!@submitter.completed_at? && !@submitter.declined_at? &&
54+
!submission.archived_at? && !submission.expired? && !submission.template&.archived_at?
55+
end
56+
5157
def maybe_resend_email_sms(submitter, params)
5258
if params[:send_email] == '1' && submitter.email.present?
5359
is_sent_recently = Docuseal.multitenant? &&

app/controllers/submitters_resubmit_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class SubmittersResubmitController < ApplicationController
55

66
def update
77
return redirect_to submit_form_path(slug: @submitter.slug) if @submitter.email != current_user.email
8+
return redirect_to submit_form_path(slug: @submitter.slug) if @submitter.completed_at.blank? ||
9+
@submitter.completed_at < 1.month.ago
810

911
submission = @submitter.account.submissions.new(created_by_user: current_user,
1012
submitters_order: :preserved,

app/controllers/template_documents_modify_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def create
1010
params.require(:documents).map do |item|
1111
item.permit(:attachment_uuid,
1212
pages: [:attachment_uuid, :page, :rotate,
13-
{ redact: [%i[x y w h]], replaced_page: %i[attachment_uuid page] }]).to_h
13+
{ redact: [%i[x y w h color]], replaced_page: %i[attachment_uuid page] }]).to_h
1414
end
1515

1616
Templates::ModifyDocuments.call(@template, documents_layout)

app/javascript/template_builder/documents_editor_page.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
<div
3737
v-for="(rect, rectIndex) in page.redact"
3838
:key="`redact-${rectIndex}`"
39-
class="absolute bg-black"
39+
class="absolute"
40+
:class="rect.color === 'white' ? 'bg-white' : 'bg-black'"
4041
:style="{
4142
left: `${rect.x * 100}%`,
4243
top: `${rect.y * 100}%`,

app/javascript/template_builder/documents_editor_redact.vue

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
<div
2323
v-for="(rect, rectIndex) in redactRects"
2424
:key="`rect-${rectIndex}`"
25-
class="absolute bg-black pointer-events-none"
25+
class="absolute pointer-events-none"
26+
:class="color === 'white' ? 'bg-white' : 'bg-black'"
2627
:style="{
2728
left: `${rect.x * 100}%`,
2829
top: `${rect.y * 100}%`,
@@ -47,6 +48,26 @@
4748
</div>
4849
</div>
4950
<div class="w-56 flex-none border-l px-4 py-4 space-y-2">
51+
<div class="flex items-center justify-between mb-1">
52+
<span class="text-sm pl-1">{{ t('color') }}</span>
53+
<div
54+
class="join rounded"
55+
style="height: 28px"
56+
>
57+
<button
58+
v-for="option in colors"
59+
:key="option"
60+
class="btn btn-sm join-item !h-7 !min-h-0 bg-white input-bordered hover:border-base-content/20 hover:bg-base-100/50 px-2"
61+
:class="{ '!bg-base-200': color === option }"
62+
@click.prevent="color = option"
63+
>
64+
<span
65+
class="block w-10 h-4 border border-base-content/30"
66+
:style="{ backgroundColor: option }"
67+
/>
68+
</button>
69+
</div>
70+
</div>
5071
<button
5172
class="btn btn-sm w-full justify-start normal-case font-normal rounded disabled:bg-base-300"
5273
:disabled="!hasRedactions && !wasReset"
@@ -122,11 +143,15 @@ export default {
122143
selectedNodes: {},
123144
freeRects: [],
124145
rects: [],
146+
color: 'black',
125147
wasReset: false,
126148
marquee: null
127149
}
128150
},
129151
computed: {
152+
colors () {
153+
return ['black', 'white']
154+
},
130155
rotate () {
131156
return this.page.rotate || 0
132157
},
@@ -186,6 +211,10 @@ export default {
186211
}
187212
},
188213
created () {
214+
if ((this.page.redact || []).some((rect) => rect.color === 'white')) {
215+
this.color = 'white'
216+
}
217+
189218
if (this.imagePage) {
190219
this.rects = (this.page.redact || []).map((rect) => ({ ...rect }))
191220
@@ -238,7 +267,17 @@ export default {
238267
return { x, y }
239268
},
240269
apply () {
241-
this.$emit('apply', this.redactRects)
270+
const rects = this.redactRects.map((rect) => {
271+
const next = { x: rect.x, y: rect.y, w: rect.w, h: rect.h }
272+
273+
if (this.color === 'white') {
274+
next.color = 'white'
275+
}
276+
277+
return next
278+
})
279+
280+
this.$emit('apply', rects)
242281
},
243282
reset () {
244283
this.wasReset = true

app/javascript/template_builder/i18n.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const en = {
111111
flip_horizontal: 'Flip horizontal',
112112
flip_vertical: 'Flip vertical',
113113
there_is_no_text_to_redact_on_this_page: 'This page contains only images. Redact tool can be used only with text pages',
114+
color: 'Color',
114115
reset: 'Reset',
115116
upload_to_document: 'Upload to "{document}"',
116117
replace_existing_document: 'Replace existing document',
@@ -351,6 +352,7 @@ const es = {
351352
flip_horizontal: 'Voltear horizontal',
352353
flip_vertical: 'Voltear vertical',
353354
there_is_no_text_to_redact_on_this_page: 'Esta página contiene solo imágenes. La herramienta de censura solo puede usarse con páginas de texto',
355+
color: 'Color',
354356
reset: 'Restablecer',
355357
upload_to_document: 'Subir a "{document}"',
356358
replace_existing_document: 'Reemplazar documento existente',
@@ -597,6 +599,7 @@ const it = {
597599
flip_horizontal: 'Rifletti orizzontale',
598600
flip_vertical: 'Rifletti verticale',
599601
there_is_no_text_to_redact_on_this_page: 'Questa pagina contiene solo immagini. Lo strumento di oscuramento può essere usato solo con pagine di testo',
602+
color: 'Colore',
600603
reset: 'Reimposta',
601604
upload_to_document: 'Carica in "{document}"',
602605
replace_existing_document: 'Sostituisci documento esistente',
@@ -837,6 +840,7 @@ const pt = {
837840
flip_horizontal: 'Inverter horizontal',
838841
flip_vertical: 'Inverter vertical',
839842
there_is_no_text_to_redact_on_this_page: 'Esta página contém apenas imagens. A ferramenta de censura só pode ser usada com páginas de texto',
843+
color: 'Cor',
840844
reset: 'Redefinir',
841845
upload_to_document: 'Enviar para "{document}"',
842846
replace_existing_document: 'Substituir documento existente',
@@ -1083,6 +1087,7 @@ const fr = {
10831087
flip_horizontal: 'Miroir horizontal',
10841088
flip_vertical: 'Miroir vertical',
10851089
there_is_no_text_to_redact_on_this_page: 'Cette page ne contient que des images. L\'outil de caviardage ne peut être utilisé qu\'avec des pages de texte',
1090+
color: 'Couleur',
10861091
reset: 'Réinitialiser',
10871092
upload_to_document: 'Téléverser dans "{document}"',
10881093
replace_existing_document: 'Remplacer le document existant',
@@ -1326,6 +1331,7 @@ const de = {
13261331
flip_horizontal: 'Horizontal spiegeln',
13271332
flip_vertical: 'Vertikal spiegeln',
13281333
there_is_no_text_to_redact_on_this_page: 'Diese Seite enthält nur Bilder. Das Schwärzungswerkzeug kann nur mit Textseiten verwendet werden',
1334+
color: 'Farbe',
13291335
reset: 'Zurücksetzen',
13301336
upload_to_document: 'In "{document}" hochladen',
13311337
replace_existing_document: 'Vorhandenes Dokument ersetzen',
@@ -1569,6 +1575,7 @@ const nl = {
15691575
flip_horizontal: 'Horizontaal spiegelen',
15701576
flip_vertical: 'Verticaal spiegelen',
15711577
there_is_no_text_to_redact_on_this_page: 'Deze pagina bevat alleen afbeeldingen. De redactietool kan alleen worden gebruikt met tekstpagina\'s',
1578+
color: 'Kleur',
15721579
reset: 'Opnieuw instellen',
15731580
upload_to_document: 'Uploaden naar "{document}"',
15741581
replace_existing_document: 'Bestaand document vervangen',

0 commit comments

Comments
 (0)