Skip to content

Commit

Permalink
Merge branch 'develop' into multiedit-e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Jul 10, 2024
2 parents 4431c3c + fad86cf commit da919fe
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class AuthoringAngularTemplateIntegration extends React.PureComponent<IPr

return fieldsData;
}}
autoFocus={false}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ interface IPropsWrapper extends IProps {
fieldsData: IFieldsData,
computeLatestEntity: IExposedFromAuthoring<IArticle>['getLatestItem'],
): IFieldsData;

autoFocus?: boolean; // defaults to true
}

/**
Expand Down Expand Up @@ -488,6 +490,7 @@ export class AuthoringIntegrationWrapper extends React.PureComponent<IPropsWrapp
getSideWidgetIdAtIndex={(article, index) => {
return getWidgetsFromExtensions(article)[index]._id;
}}
autoFocus={this.props.autoFocus}
/>
);
}}
Expand Down
2 changes: 1 addition & 1 deletion scripts/apps/authoring-react/authoring-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export class AuthoringReact<T extends IBaseRestApiResponse> extends React.PureCo

this.setState(initialState);

if (this.componentRef != null) {
if (this.componentRef != null && this.props.autoFocus !== false) {
this.cleanupFunctionsToRunBeforeUnmounting.push(focusFirstChildInput(this.componentRef).cancel);
}
});
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/multi-edit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export class MultiEditModal extends React.PureComponent<IProps, IState> {
getInlineToolbarActions={(options) =>
this.getInlineToolbarActions(options, availableArticles)
}
autoFocus={false}
/>
</div>
</Spacer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,10 @@ export function AuthoringDirective(
if (event.detail.itemId === $scope.item._id) {
angular.extend($scope.item, {[event.detail.field.key]: event.detail.field.value});

if ($scope.item.fields_meta != null) {
delete $scope.item.fields_meta[event.detail.field.key];
}

$scope.dirty = true;
$scope.$applyAsync();
$scope.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ AuthoringHeaderDirective.$inject = [
'features',
'TranslationService',
'authoringWorkspace',
'$location',
];
export function AuthoringHeaderDirective(
api,
Expand All @@ -36,6 +37,7 @@ export function AuthoringHeaderDirective(
features,
TranslationService,
authoringWorkspace: AuthoringWorkspaceService,
$location,
) {
return {
templateUrl: 'scripts/apps/authoring/views/authoring-header.html',
Expand Down Expand Up @@ -307,52 +309,57 @@ export function AuthoringHeaderDirective(
const loadingStartTimestamp = Date.now();
let lastElementCount = null;

/**
* Use interval to approximately determine when fields have loaded.
*/
const interval = setInterval(() => {
if (Date.now() - loadingStartTimestamp > 5000) {
// stop trying after 5s
// there might not be inputs in authoring header configured
clearInterval(interval);
} else {
const elements = [...elem[0].querySelectorAll('input, textarea, [contenteditable]')];

if (elements.length < 1) {
return;
} else if (lastElementCount == null) {
lastElementCount = elements.length;
// authoring-angular specific workaround
const autofocus = $location.url() !== '/settings/templates' && $location.url() !== '/multiedit';

if (autofocus) {
/**
* Use interval to approximately determine when fields have loaded.
*/
const interval = setInterval(() => {
if (Date.now() - loadingStartTimestamp > 5000) {
// stop trying after 5s
// there might not be inputs in authoring header configured
clearInterval(interval);
} else {
const elements = [...elem[0].querySelectorAll('input, textarea, [contenteditable]')];

return;
} else if (lastElementCount !== elements.length) {
lastElementCount = elements.length;
if (elements.length < 1) {
return;
} else if (lastElementCount == null) {
lastElementCount = elements.length;

return;
} else {
clearInterval(interval);
}
return;
} else if (lastElementCount !== elements.length) {
lastElementCount = elements.length;

if (scope.action === 'correct') {
elem.find('#ednote').focus();
} else {
const sorted = elements
.map((el) => {
const orderEl = el.closest('[order]');

return {
input: el,
order: orderEl == null ? null : parseInt(orderEl.getAttribute('order'), 10),
};
})
.filter(({order}) => order != null)
.sort((a, b) => a.order - b.order);

if (sorted.length > 0) {
sorted[0].input.focus();
return;
} else {
clearInterval(interval);
}

if (scope.action === 'correct') {
elem.find('#ednote').focus();
} else {
const sorted = elements
.map((el) => {
const orderEl = el.closest('[order]');

return {
input: el,
order: orderEl == null ? null : parseInt(orderEl.getAttribute('order'), 10),
};
})
.filter(({order}) => order != null)
.sort((a, b) => a.order - b.order);

if (sorted.length > 0) {
sorted[0].input.focus();
}
}
}
}
}, 100);
}, 100);
}
},
};
}
8 changes: 8 additions & 0 deletions scripts/apps/users/views/user-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ <h3 id="notifications" class="sd-heading sd-text-align--left sd-text--sans sd-he
<span ng-hide="preferences['desktop:notification'].allowed" sd-switch ng-model="preferences['desktop:notification'].enabled"></span>
<label>{{ :: preferences['desktop:notification'].label | translate }}</label>
</div>
<div sd-info-item ng-show="preferences['assignment:notification']">
<span ng-hide="preferences['assignment:notification'].allowed" sd-switch ng-model="preferences['assignment:notification'].enabled"></span>
<label>{{ preferences['assignment:notification'].label }}</label>
</div>
<div sd-info-item ng-show="preferences['mark_for_user:notification']">
<span ng-hide="preferences['mark_for_user:notification'].allowed" sd-switch ng-model="preferences['mark_for_user:notification'].enabled"></span>
<label>{{ preferences['mark_for_user:notification'].label }}</label>
</div>
<div sd-info-item ng-hide="!$root.config.features.slackNotifications">
<span ng-hide="preferences['slack:notification'].allowed" sd-switch ng-model="preferences['slack:notification'].enabled"></span>
<label>{{ :: preferences['slack:notification'].label | translate }}</label>
Expand Down
2 changes: 2 additions & 0 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ declare module 'superdesk-api' {
headerCollapsed?: boolean; // initial value

themingEnabled?: boolean; // only works with article; default false

autoFocus?: boolean; // defaults to true; will focus first input
}

// AUTHORING-REACT FIELD TYPES - attachments
Expand Down

0 comments on commit da919fe

Please sign in to comment.