Skip to content

Commit

Permalink
merging release/1.32 to develop (#3209)
Browse files Browse the repository at this point in the history
* use older chromedriver version (#3116)

* add error/success notifications for unpublish actions (#3091)

* add error/success notifications for unpublish actions

Unpublish action can fail when the item is in a package.

SDFID-573

* use error message from server

* release 1.31.2

* Fix left hand sidebar configuration issues (#3132)

* fix permissions check so it works with any route set as default, not only the dashboard.

* Include a link to personal space" in hamburger menu so users who don't have a dashboard privilege can get back to authoring view.

* fix lint

* copy metadata in media editor based on picture schema (#3136)

* [SDANSA-327] List of routed desk (#3140)

* use component for editing metadata in gallery (#3150)

it handles pasting html properly unlike contenteditable

SDANSA-330

* description field is missing due to markup

SDANSA-330

* re-implement hiding of nested items (#3146)

* re-implement hiding of nested items

when it's activated filter out nested items via
query and fetch previous items from server when
needed.

SDFID-580 SDESK-4709

* [SDESK-4708] Create filter condition on on existence of featuremedia (#3152)

* Internal attachments (#3120)

* wip

* Disable internal attachment links

* Render attachment logic

* lint

* Missing trailing commas

* Refactor attachment list component

* Div -> null

* adjust height automatically for sms text input (#3159)

SDANSA-332

* implement sent items filter in personal space (#3163)

* implement sent items filter in personal space

SDANSA-339

* [SDANSA-329] fix(carousel): Fixed issue with carousel on resize (#3160)

* feix(carousel): Fixed issue with carousel on resize

* fix(resize): Added event trigger for splitter resize also

* feat(event): Moved resize event to superdeskView component

* fix(import): Removed unused import

* add config for editor3 draft features (#3180)

* add config for browser spell check in editor3
* make strip pasted html configurable via content profile

SDANSA-341

* Remove responsive iframes (#3184)

* Remove responsive iframes

* Display help message on tooltip

* Use gettext instead of translate tags

* As a user I want to "save, close, and update" a story I am editing. (SDBELGA-197) (#3164)

* As a user I want to "save, close, and update" a story I am editing. (SDBELGA-197)

* fix lint

* [SDESK-4790] - Shortcut buttons checking user privileges (#3182)

* [SDESK-4790] - Shortcut buttons checking user privileges

* Few improvements per comments and an error message is added

* fix(products): Fixed issue with removing products after reverting version (#3178)

* fix(products): Fixed issue with removing products after reverting version

* fix(without): Fixed issue with without on removeTerms directive

* Add order to the media items when added to media gallery. (SDESK-4423) (#3158)

* Add order to the media-gallery items when added to media gallery. (SDESK-4423)

* fix comment

* fix(kill): Item schema not loading when killing from archived (#3149)

* draft did remove some styles, but not all (#3197)

* draft did remove some styles, but not all
* fix line breaks when pasting plain text

SDANSA-341

* Fix editor3 paste initial space (#3202)

* fix missing spaces when pasting text to editor3

hacking draft convertFromHTML

SDANSA-341 SDANSA-348

* fix invisible ingest routing schemas (#3206)

* fix invisible ingest routing schemas

temporary fix for missing pagination

SDANSA-350

* fix ingest routing schema limit in ingest source modal (#3207)

SDANSA-350

* Don't duplicate annotation from library when reusing it (#3200)

SDESK-4800

* Fix annotation library breaking after editing one item (#3204)

SDESK-4801

If the item was not on page 1, updating the item would cause pagination
to go back to page 1 and that was making the component not find the
open item inside the current fetched data (cause it was looking on page
1 instead of page X)

* fix tests
  • Loading branch information
petrjasek authored Nov 14, 2019
1 parent c50a264 commit cf922f4
Show file tree
Hide file tree
Showing 45 changed files with 2,374 additions and 586 deletions.
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(config) {

// in karma, entry is read from files prop
webpackConfig.entry = null;
webpackConfig.devtool = 'inline-source-map';
webpackConfig.devtool = 'eval';

config.set({
frameworks: [
Expand Down
40 changes: 26 additions & 14 deletions scripts/apps/archive/controllers/UploadAttachmentsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@ export function UploadAttachmentsController($scope, $q, urls, upload) {
* Upload file
*/
function uploadFile(item) {
item.promise = urls.resource('attachments')
.then((uploadURL) => upload.start({
method: 'POST',
url: uploadURL,
data: {media: item.file, title: item.meta.title, description: item.meta.description},
}))
.then((response) => {
item.attachment = response.data;
return item.attachment;
}, (error) => {
item.error = error;
}, (progress) => {
item.progress = progress.loaded / progress.total * 100.0;
});
item.promise = urls
.resource('attachments')
.then((uploadURL) =>
upload.start({
method: 'POST',
url: uploadURL,
data: {
media: item.file,
title: item.meta.title,
description: item.meta.description,
internal: item.meta.internal,
},
}),
)
.then(
(response) => {
item.attachment = response.data;
return item.attachment;
},
(error) => {
item.error = error;
},
(progress) => {
item.progress = (progress.loaded / progress.total) * 100.0;
},
);

return item.promise;
}
Expand Down
34 changes: 15 additions & 19 deletions scripts/apps/archive/views/upload-attachments.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@ <h3 class="modal__heading">{{ activity.label | translate }}</h3>
<div class="bar" style="width:{{ item.progress }}%"></div>
</div>
<div class="other-info">
<div class="form__row">
<label>Title *</label>
<input type="text" required ng-model="item.meta.title" class="contenteditable-input" />
<div class="sd-line-input">
<label translate>Internal</label><span ng-model="item.meta.internal" sd-switch></span>
</div>
<div class="form__row">
<label>Description *</label>
<textarea class="contenteditable-input"
ng-model="item.meta.description"
sd-auto-height
required></textarea>
<div class="sd-line-input sd-line-input--boxed sd-line-input--required">
<label class="sd-line-input__label" translate>Title</label>
<input class="sd-line-input__input" type="text" ng-model="item.meta.title" required>
</div>
<div class="form__row">
<label translate>File Name</label>
<div class="contenteditable-input">
{{ :: item.file.name }}
</div>
<div class="sd-line-input sd-line-input--boxed sd-line-input--required">
<label class="sd-line-input__label" translate>Description</label>
<input class="sd-line-input__input" type="text" ng-model="item.meta.description" required>
</div>
<div class="form__row">
<label translate>File Size</label>
<div class="contenteditable-input">
{{ :: item.file.size | filesize }}
</div>
<div class="sd-line-input sd-line-input--boxed">
<label class="sd-line-input__label" translate>File Name</label>
<input class="sd-line-input__input" type="text" ng-model="item.file.name" disabled>
</div>
<div class="sd-line-input sd-line-input--boxed">
<label class="sd-line-input__label" translate>File Size</label>
<input class="sd-line-input__input" type="text" ng-model="item.file.size" disabled>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions scripts/apps/authoring/attachments/AttachmentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class AttachmentsListComponent extends React.PureComponent<IProps> {
<Row>
<div className="description">{file.description}</div>
</Row>
{
file.internal === true &&
<Row>
<span className="label label--orange2">internal</span>
</Row>
}
</Column>
<ActionMenu row={true}>
<button className="dropdown__toggle"
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring/attachments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface IAttachment {
filename: string;
description: string;
media: IMedia;
internal: boolean;
}
30 changes: 23 additions & 7 deletions scripts/apps/authoring/media/MediaCopyMetadataDirective.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import {keys, pick, merge} from 'lodash';
import {merge} from 'lodash';

function getMediaMetadata(metadata, fields) {
const output = {extra: {}};

if (metadata == null) {
return output;
}

fields.forEach((field) => {
if (field.extra) {
if (metadata.extra != null && metadata.extra[field.field] != null) {
output.extra[field.field] = metadata.extra[field.field];
}
} else if (metadata[field.field] != null) {
output[field.field] = metadata[field.field];
}
});

return output;
}

MediaCopyMetadataDirective.$inject = [];
export default function MediaCopyMetadataDirective() {
Expand All @@ -7,21 +27,17 @@ export default function MediaCopyMetadataDirective() {
metadata: '=',
validator: '=',
onChange: '&',
fields: '=',
},
template: require('./views/media-copy-metadata-directive.html'),
link: (scope) => {
const METADATA_ITEMS = 'metadata:items';
const FIELD_KEYS = keys(scope.validator);

const METADATA_FIELDS = [
'subject',
].concat(FIELD_KEYS);

scope.metadataFromStorage = !!localStorage.getItem(METADATA_ITEMS);

scope.copyMetadata = (metadata) => {
scope.metadataFromStorage = true;
localStorage.setItem(METADATA_ITEMS, JSON.stringify(pick(metadata, METADATA_FIELDS)));
localStorage.setItem(METADATA_ITEMS, JSON.stringify(getMediaMetadata(metadata, scope.fields)));
};

scope.pasteMetadata = () => {
Expand Down
142 changes: 41 additions & 101 deletions scripts/apps/authoring/media/MediaMetadataEditorDirective.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
import {max, sortBy, get, isEmpty} from 'lodash';
import {getLabelNameResolver} from 'apps/workspace/helpers/getLabelForFieldId';
import {appConfig} from 'appConfig';

MediaMetadataEditorDirective.$inject = ['metadata', 'features', '$q', 'session'];
export default function MediaMetadataEditorDirective(metadata, features, $q, session) {
function getCV(field) {
const cv = metadata.cvs.find((_cv) => _cv._id === field || _cv.schema_field === field);

if (cv == null && field === 'subject') {
// fallback for built in subjectcodes
return {selection_type: 'multi selection', items: metadata.values.subjectcodes};
}

if (cv == null && field === 'language' && metadata.values.languages) {
// keep it consistent with authoring
return {schema_field: 'language', items: metadata.values.languages, key: 'qcode'};
}

return cv;
}

function isExtra(field): boolean {
return field.cv && (field.cv.field_type === 'text' || field.cv.field_type === 'date');
}
import {get, isEmpty} from 'lodash';

MediaMetadataEditorDirective.$inject = ['metadata', 'features', 'session'];
export default function MediaMetadataEditorDirective(metadata, features, session) {
return {
scope: {
item: '=',
Expand All @@ -36,90 +14,52 @@ export default function MediaMetadataEditorDirective(metadata, features, $q, ses
boxed: '@',
associated: '=',
multi: '=',
fields: '=',
},
template: require('./views/media-metadata-editor-directive.html'),
link: (scope) => {
scope.features = features;
scope.metadata = metadata;

$q.all({
getLabelForFieldId: getLabelNameResolver(),
metadataInit: metadata.initialize(),
}).then(({getLabelForFieldId}) => {
const editor = get(appConfig.editor, 'picture', {});
const schema = get(appConfig.schema, 'picture', {});

// get last order
let nextOrder = max(Object.keys(editor).map((field) => get(editor, `${field}.order`, 0))) + 1;

// add missing fields from validator to editor/schema
Object.keys(scope.validator || {}).forEach((field) => {
if (!editor[field]) {
editor[field] = {
type: scope.validator[field].type || null,
order: scope.validator[field].order || nextOrder++,
};
schema[field] = scope.validator[field];
}
});

// set scope fields in order.
// Only display fields required on the media editor based on the value of `displayOnMediaEditor`.
// default is set to true to display all fields.
scope.fields = sortBy(
Object.keys(editor)
.filter((key) => editor[key] != null)
.filter((key) => get(editor[key], 'displayOnMediaEditor', true))
.map((field) => Object.assign({
field: field,
label: getLabelForFieldId(field),
cv: getCV(field),
}, editor[field], schema[field])),
(field) => field.section === 'header' ? field.order : field.order + 1000,
);

scope.$applyAsync();

// set default values
scope.$watch('item', (item) => {
if (!item) {
return;
}

if (item._id && (!item._locked || !item._editable)) {
return;
}

if (!scope.fields) {
return;
}

scope.fields
.filter((field) => !isEmpty(field.default))
.forEach((field) => {
const dest = field.cv ? (field.cv.schema_field || field.field) : field.field;

if (isExtra(field)) {
if (!item.extra || !item.extra.hasOwnProperty(dest)) {
item.extra = item.extra || {};
item.extra[dest] = field.default;
// only call on change for single image editing, not multi upload
// it would override other extra values
if (!scope.multi) {
scope.onChange({key: 'extra'});
}
// set default values
scope.$watch('item', (item) => {
if (!item) {
return;
}

if (item._id && (!item._locked || !item._editable)) {
return;
}

if (!scope.fields) {
return;
}

scope.fields
.filter((field) => !isEmpty(field.default))
.forEach((field) => {
const dest = field.cv ? (field.cv.schema_field || field.field) : field.field;

if (field.extra) {
if (!item.extra || !item.extra.hasOwnProperty(dest)) {
item.extra = item.extra || {};
item.extra[dest] = field.default;
// only call on change for single image editing, not multi upload
// it would override other extra values
if (!scope.multi) {
scope.onChange({key: 'extra'});
}
} else if (!item.hasOwnProperty(dest)) {
item[dest] = field.default;
scope.onChange({key: dest});
}
});

// populate fields for current user
if (get(session, 'identity.sign_off') && !item.hasOwnProperty('sign_off')) {
item.sign_off = session.identity.sign_off;
}
});
} else if (!item.hasOwnProperty(dest)) {
item[dest] = field.default;
scope.onChange({key: dest});
}
});

// populate fields for current user
if (get(session, 'identity.sign_off') && !item.hasOwnProperty('sign_off')) {
item.sign_off = session.identity.sign_off;
}
});

/**
Expand Down
2 changes: 2 additions & 0 deletions scripts/apps/authoring/media/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import MediaMetadataEditorDirective from './MediaMetadataEditorDirective';
import MediaMetadataViewDirective from './MediaMetadataViewDirective';
import MediaCopyMetadataDirective from './MediaCopyMetadataDirective';
import MediaFieldsController from './media-fields-controller';

export default angular.module('superdesk.apps.authoring.media', [])
.directive('sdMediaMetadataEditor', MediaMetadataEditorDirective)
.directive('sdMediaMetadataView', MediaMetadataViewDirective)
.directive('sdMediaCopyMetadata', MediaCopyMetadataDirective)
.controller('MediaFieldsController', MediaFieldsController)
;
Loading

0 comments on commit cf922f4

Please sign in to comment.