Add ability to reset originallyPublishedAt

This commit is contained in:
Chocobozzz 2023-08-18 11:40:54 +02:00
parent ca589b42f1
commit 7ace48819e
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
8 changed files with 60 additions and 48 deletions

View File

@ -226,7 +226,7 @@
</div>
<div class="submit-button">
<button i18n class="reset-button" (click)="reset()" *ngIf="advancedSearch.size()">
<button i18n class="reset-button me-3" (click)="reset()" *ngIf="advancedSearch.size()">
Reset
</button>

View File

@ -34,27 +34,3 @@ input[type=submit] {
.submit-button {
text-align: end;
}
.reset-button {
@include peertube-button;
@include margin-right(1rem);
font-weight: $font-semibold;
display: inline-block;
padding: 0 10px;
white-space: nowrap;
background: transparent;
}
.reset-button-small {
font-size: 80%;
height: unset;
line-height: unset;
margin: unset;
margin-bottom: 0.5rem;
}
.label-container {
display: flex;
white-space: nowrap;
}

View File

@ -365,14 +365,18 @@
</div>
<div class="form-group originally-published-at">
<div class="label-container">
<label i18n for="originallyPublishedAt">Original publication date</label>
<my-help>
<ng-template ptTemplate="preHtml">
<ng-container i18n>
<button i18n class="reset-button reset-button-small" (click)="resetField('originallyPublishedAt')" *ngIf="hasPublicationDate()">
Reset
</button>
</div>
<div class="form-group-description" i18n>
This is the date when the content was originally published (e.g. the release date for a film)
</ng-container>
</ng-template>
</my-help>
</div>
<p-calendar
id="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" [firstDayOfWeek]="0"
[showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange"

View File

@ -264,6 +264,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
if (this.schedulerInterval) clearInterval(this.schedulerInterval)
}
// ---------------------------------------------------------------------------
getExistingCaptions () {
return this.videoCaptions
.filter(c => c.action !== 'REMOVE')
@ -312,6 +314,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this))
}
// ---------------------------------------------------------------------------
isSaveReplayAllowed () {
return this.serverConfig.live.allowReplay
}
@ -328,6 +332,18 @@ export class VideoEditComponent implements OnInit, OnDestroy {
return this.serverConfig.live.latencySetting.enabled
}
hasPublicationDate () {
return !!this.form.value['originallyPublishedAt']
}
// ---------------------------------------------------------------------------
resetField (name: string) {
this.form.patchValue({ [name]: null })
}
// ---------------------------------------------------------------------------
isPluginFieldHidden (pluginField: PluginField) {
if (typeof pluginField.commonOptions.hidden !== 'function') return false

View File

@ -13,7 +13,7 @@
<div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div>
<button *ngIf="displayReset && filename" i18n class="reset-button" (click)="reset()">
<button *ngIf="displayReset && filename" i18n class="reset-button reset-button-small ms-2" (click)="reset()">
Reset
</button>
</div>

View File

@ -19,15 +19,4 @@
font-weight: $font-semibold;
}
.reset-button {
@include peertube-button;
@include grey-button;
font-size: 80%;
margin-left: 5px;
line-height: initial;
padding: 2px 5px;
height: auto;
}
}

View File

@ -49,7 +49,32 @@
margin-top: 10px;
}
label+.form-group-description {
// Useful with a "reset" button
.label-container {
display: flex;
white-space: nowrap;
align-items: baseline;
}
label + .form-group-description,
.label-container + .form-group-description {
margin-bottom: 10px;
margin-top: 0;
}
.reset-button {
@include peertube-button;
@include grey-button;
height: auto;
&.reset-button-small {
font-size: 80%;
padding: 2px 5px;
margin: 0 0.25rem;
height: fit-content;
line-height: initial;
}
}

View File

@ -86,8 +86,10 @@ async function updateVideo (req: express.Request, res: express.Response) {
if (videoInfoToUpdate[key] !== undefined) video.set(key, videoInfoToUpdate[key])
}
if (videoInfoToUpdate.originallyPublishedAt !== undefined && videoInfoToUpdate.originallyPublishedAt !== null) {
video.originallyPublishedAt = new Date(videoInfoToUpdate.originallyPublishedAt)
if (videoInfoToUpdate.originallyPublishedAt !== undefined) {
video.originallyPublishedAt = videoInfoToUpdate.originallyPublishedAt
? new Date(videoInfoToUpdate.originallyPublishedAt)
: null
}
// Privacy update?