aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-08-18 11:40:54 +0200
committerChocobozzz <me@florianbigard.com>2023-08-18 11:40:54 +0200
commit7ace48819edc63f19f28ba3eedbbfbaa7c6504bd (patch)
treebc0fcf2fc9e1da9184d7581de2cf063e83ab00d0
parentca589b42f1159d4474d7803c02b0c90579316bd5 (diff)
downloadPeerTube-7ace48819edc63f19f28ba3eedbbfbaa7c6504bd.tar.gz
PeerTube-7ace48819edc63f19f28ba3eedbbfbaa7c6504bd.tar.zst
PeerTube-7ace48819edc63f19f28ba3eedbbfbaa7c6504bd.zip
Add ability to reset originallyPublishedAt
-rw-r--r--client/src/app/+search/search-filters.component.html2
-rw-r--r--client/src/app/+search/search-filters.component.scss24
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.html20
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts16
-rw-r--r--client/src/app/shared/shared-forms/reactive-file.component.html2
-rw-r--r--client/src/app/shared/shared-forms/reactive-file.component.scss11
-rw-r--r--client/src/sass/class-helpers/_forms.scss27
-rw-r--r--server/server/controllers/api/videos/update.ts6
8 files changed, 60 insertions, 48 deletions
diff --git a/client/src/app/+search/search-filters.component.html b/client/src/app/+search/search-filters.component.html
index ed0632a4d..5b9237379 100644
--- a/client/src/app/+search/search-filters.component.html
+++ b/client/src/app/+search/search-filters.component.html
@@ -226,7 +226,7 @@
226 </div> 226 </div>
227 227
228 <div class="submit-button"> 228 <div class="submit-button">
229 <button i18n class="reset-button" (click)="reset()" *ngIf="advancedSearch.size()"> 229 <button i18n class="reset-button me-3" (click)="reset()" *ngIf="advancedSearch.size()">
230 Reset 230 Reset
231 </button> 231 </button>
232 232
diff --git a/client/src/app/+search/search-filters.component.scss b/client/src/app/+search/search-filters.component.scss
index c55e59310..fd997d33b 100644
--- a/client/src/app/+search/search-filters.component.scss
+++ b/client/src/app/+search/search-filters.component.scss
@@ -34,27 +34,3 @@ input[type=submit] {
34.submit-button { 34.submit-button {
35 text-align: end; 35 text-align: end;
36} 36}
37
38.reset-button {
39 @include peertube-button;
40 @include margin-right(1rem);
41
42 font-weight: $font-semibold;
43 display: inline-block;
44 padding: 0 10px;
45 white-space: nowrap;
46 background: transparent;
47}
48
49.reset-button-small {
50 font-size: 80%;
51 height: unset;
52 line-height: unset;
53 margin: unset;
54 margin-bottom: 0.5rem;
55}
56
57.label-container {
58 display: flex;
59 white-space: nowrap;
60}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html
index ea9909612..f3c1f1634 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html
@@ -365,14 +365,18 @@
365 </div> 365 </div>
366 366
367 <div class="form-group originally-published-at"> 367 <div class="form-group originally-published-at">
368 <label i18n for="originallyPublishedAt">Original publication date</label> 368 <div class="label-container">
369 <my-help> 369 <label i18n for="originallyPublishedAt">Original publication date</label>
370 <ng-template ptTemplate="preHtml"> 370
371 <ng-container i18n> 371 <button i18n class="reset-button reset-button-small" (click)="resetField('originallyPublishedAt')" *ngIf="hasPublicationDate()">
372 This is the date when the content was originally published (e.g. the release date for a film) 372 Reset
373 </ng-container> 373 </button>
374 </ng-template> 374 </div>
375 </my-help> 375
376 <div class="form-group-description" i18n>
377 This is the date when the content was originally published (e.g. the release date for a film)
378 </div>
379
376 <p-calendar 380 <p-calendar
377 id="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" [firstDayOfWeek]="0" 381 id="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" [firstDayOfWeek]="0"
378 [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange" 382 [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange"
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index b0c1352f3..898d3b0a6 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -264,6 +264,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
264 if (this.schedulerInterval) clearInterval(this.schedulerInterval) 264 if (this.schedulerInterval) clearInterval(this.schedulerInterval)
265 } 265 }
266 266
267 // ---------------------------------------------------------------------------
268
267 getExistingCaptions () { 269 getExistingCaptions () {
268 return this.videoCaptions 270 return this.videoCaptions
269 .filter(c => c.action !== 'REMOVE') 271 .filter(c => c.action !== 'REMOVE')
@@ -312,6 +314,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
312 modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this)) 314 modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this))
313 } 315 }
314 316
317 // ---------------------------------------------------------------------------
318
315 isSaveReplayAllowed () { 319 isSaveReplayAllowed () {
316 return this.serverConfig.live.allowReplay 320 return this.serverConfig.live.allowReplay
317 } 321 }
@@ -328,6 +332,18 @@ export class VideoEditComponent implements OnInit, OnDestroy {
328 return this.serverConfig.live.latencySetting.enabled 332 return this.serverConfig.live.latencySetting.enabled
329 } 333 }
330 334
335 hasPublicationDate () {
336 return !!this.form.value['originallyPublishedAt']
337 }
338
339 // ---------------------------------------------------------------------------
340
341 resetField (name: string) {
342 this.form.patchValue({ [name]: null })
343 }
344
345 // ---------------------------------------------------------------------------
346
331 isPluginFieldHidden (pluginField: PluginField) { 347 isPluginFieldHidden (pluginField: PluginField) {
332 if (typeof pluginField.commonOptions.hidden !== 'function') return false 348 if (typeof pluginField.commonOptions.hidden !== 'function') return false
333 349
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.html b/client/src/app/shared/shared-forms/reactive-file.component.html
index 8e38697e4..33bb88f1f 100644
--- a/client/src/app/shared/shared-forms/reactive-file.component.html
+++ b/client/src/app/shared/shared-forms/reactive-file.component.html
@@ -13,7 +13,7 @@
13 13
14 <div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div> 14 <div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div>
15 15
16 <button *ngIf="displayReset && filename" i18n class="reset-button" (click)="reset()"> 16 <button *ngIf="displayReset && filename" i18n class="reset-button reset-button-small ms-2" (click)="reset()">
17 Reset 17 Reset
18 </button> 18 </button>
19</div> 19</div>
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.scss b/client/src/app/shared/shared-forms/reactive-file.component.scss
index f9ba5805a..a0afe1eee 100644
--- a/client/src/app/shared/shared-forms/reactive-file.component.scss
+++ b/client/src/app/shared/shared-forms/reactive-file.component.scss
@@ -19,15 +19,4 @@
19 19
20 font-weight: $font-semibold; 20 font-weight: $font-semibold;
21 } 21 }
22
23 .reset-button {
24 @include peertube-button;
25 @include grey-button;
26
27 font-size: 80%;
28 margin-left: 5px;
29 line-height: initial;
30 padding: 2px 5px;
31 height: auto;
32 }
33} 22}
diff --git a/client/src/sass/class-helpers/_forms.scss b/client/src/sass/class-helpers/_forms.scss
index 1e78df947..4e5c98aa8 100644
--- a/client/src/sass/class-helpers/_forms.scss
+++ b/client/src/sass/class-helpers/_forms.scss
@@ -49,7 +49,32 @@
49 margin-top: 10px; 49 margin-top: 10px;
50} 50}
51 51
52label+.form-group-description { 52// Useful with a "reset" button
53.label-container {
54 display: flex;
55 white-space: nowrap;
56 align-items: baseline;
57}
58
59label + .form-group-description,
60.label-container + .form-group-description {
53 margin-bottom: 10px; 61 margin-bottom: 10px;
54 margin-top: 0; 62 margin-top: 0;
55} 63}
64
65.reset-button {
66 @include peertube-button;
67 @include grey-button;
68
69 height: auto;
70
71 &.reset-button-small {
72 font-size: 80%;
73 padding: 2px 5px;
74 margin: 0 0.25rem;
75 height: fit-content;
76 line-height: initial;
77 }
78}
79
80
diff --git a/server/server/controllers/api/videos/update.ts b/server/server/controllers/api/videos/update.ts
index 1c8cecba1..491175d74 100644
--- a/server/server/controllers/api/videos/update.ts
+++ b/server/server/controllers/api/videos/update.ts
@@ -86,8 +86,10 @@ async function updateVideo (req: express.Request, res: express.Response) {
86 if (videoInfoToUpdate[key] !== undefined) video.set(key, videoInfoToUpdate[key]) 86 if (videoInfoToUpdate[key] !== undefined) video.set(key, videoInfoToUpdate[key])
87 } 87 }
88 88
89 if (videoInfoToUpdate.originallyPublishedAt !== undefined && videoInfoToUpdate.originallyPublishedAt !== null) { 89 if (videoInfoToUpdate.originallyPublishedAt !== undefined) {
90 video.originallyPublishedAt = new Date(videoInfoToUpdate.originallyPublishedAt) 90 video.originallyPublishedAt = videoInfoToUpdate.originallyPublishedAt
91 ? new Date(videoInfoToUpdate.originallyPublishedAt)
92 : null
91 } 93 }
92 94
93 // Privacy update? 95 // Privacy update?