Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix media metadata editor changes not being saved #4572

Merged
merged 11 commits into from
Jul 22, 2024
Prev Previous commit
Next Next commit
handle feedback
  • Loading branch information
petrjasek committed Jul 16, 2024
commit d640969bad5b6b129bcd8f1e9769cab7076a573f
4 changes: 2 additions & 2 deletions e2e/client/playwright/authoring.picture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.setTimeout(30000);
* edit metadata
* test metadata changes from modal are visible in the editor
*/
test('edit picture metadata in modal', async ({page}) => {
test('media metadata editor', async ({page}) => {
await restoreDatabaseSnapshot();

const monitoring = new Monitoring(page);
Expand All @@ -28,7 +28,7 @@ test('edit picture metadata in modal', async ({page}) => {

await expect(mediaEditor.field('headline')).toContainText('The Headline');

await mediaEditor.field('headline').fill('');
await mediaEditor.field('headline').clear();
await mediaEditor.field('headline').fill('picture');

await mediaEditor.startUpload();
Expand Down
11 changes: 3 additions & 8 deletions e2e/client/playwright/page-object-models/authoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ export class Authoring {
.click();
}


async openMediaMetadataEditor() {
await this.page.locator(s('image-overlay')).hover();
await this.page.locator(s('edit-metadata')).click();
async openMediaMetadataEditor(field: string = 'media') {
await this.page.locator(s(`authoring-field=${field}`, 'image-overlay')).hover();
await this.page.locator(s(`authoring-field=${field}`, 'edit-metadata')).click();
}

field(field: string) {
return this.page.locator(s('authoring', 'field--' + field)).getByRole('textbox');
}

async waitForAutosave() {
await this.page.waitForResponse(/\/api\/archive_autosave/);
}
}
2 changes: 1 addition & 1 deletion scripts/apps/archive/views/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="upload__info-icon"></div>
<h3 class="upload__info-heading" translate>Drag Your Files Here</h3>
<div class="upload__info-label" translate>or</div>
<button ng-click="invokeImagesInput()" data-id="select-file-btn" class="btn btn--hollow upload__info-button" translate>Select them from folder</button>
<button ng-click="invokeImagesInput()" data-test-id="select-file-btn" class="btn btn--hollow upload__info-button" translate>Select them from folder</button>
<input ng-if="uniqueUpload" id="images-input" type="file" ngf-select="addFiles($files)" class="hide" data-test-id="image-upload-input">
<input ng-if="!uniqueUpload" id="images-input" type="file" ngf-select="addFiles($files)" multiple class="hide" data-test-id="image-upload-input">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IScope extends ng.IScope {
extra: any;
refreshTrigger: number;
autosave(item: any): any;
syncEditor(): void;
generateHtml(): void;
modifySignOff(item: any): void;
updateDateline(item: any, city: any): void;
resetNumberOfDays(dateline: any, datelineMonth?: any): void;
Expand Down Expand Up @@ -343,7 +343,7 @@ export function ArticleEditDirective(
* @description Opens the Change Image Controller to modify the image metadata.
*/
scope.editMedia = (defaultTab = 'view') => {
scope.syncEditor();
scope.generateHtml();

let showTabs = [];

Expand Down Expand Up @@ -391,7 +391,7 @@ export function ArticleEditDirective(
scope.articleEdit.$setDirty();
}
} else {
scope.save({reloadEditor3: true});
scope.save({generateHtml: false});
}
})
.finally(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ export function AuthoringDirective(
/**
* Create a new version
*/
$scope.save = function({reloadEditor3 = false} = {}) {
$scope.save = function({generateHtml = true} = {}) {
return authoring.save(
$scope.origItem,
$scope.item,
reloadEditor3 ? [] : $scope.requestEditor3DirectivesToGenerateHtml,
generateHtml ? $scope.requestEditor3DirectivesToGenerateHtml : [],
).then((res) => {
$scope.dirty = false;
_.merge($scope.item, res);
Expand Down Expand Up @@ -554,7 +554,7 @@ export function AuthoringDirective(
// delay required for loading state to render
// before possibly long operation (with huge articles)
setTimeout(() => {
$scope.syncEditor();
$scope.generateHtml();

resolve();
});
Expand Down Expand Up @@ -671,7 +671,7 @@ export function AuthoringDirective(
_closing = true;

// Request to generate html before we pass scope variables
$scope.syncEditor();
$scope.generateHtml();

// returned promise used by superdesk-fi
return authoringApiCommon.closeAuthoringStep2($scope, $rootScope);
Expand Down Expand Up @@ -852,7 +852,7 @@ export function AuthoringDirective(
$scope.firstLineConfig.wordCount = $scope.firstLineConfig.wordCount ?? true;

const _autosave = debounce((timeout) => {
$scope.syncEditor();
$scope.generateHtml();

return authoring.autosave(
$scope.item,
Expand All @@ -875,7 +875,7 @@ export function AuthoringDirective(
_autosave(timeout);
};

$scope.syncEditor = () => {
$scope.generateHtml = () => {
$scope.requestEditor3DirectivesToGenerateHtml.forEach((fn) => fn());
};

Expand Down
6 changes: 4 additions & 2 deletions scripts/apps/authoring/views/article-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@
sd-validation-error="error.media"
data-required="schema.media.required"
tabindex="{{editor.media.order}}"
sd-width="{{editor.media.sdWidth|| 'full'}}">

sd-width="{{editor.media.sdWidth|| 'full'}}"
data-test-id="authoring-field"
data-test-value="media"
>
<div ng-if="item.type == 'picture' || item.type == 'graphic'" class="full-preview" sd-ratio-calc>
<div class="media-item__item">
<div class="item-association item-association--preview">
Expand Down
Loading