Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Jul 28, 2019
2 parents a17931d + 07dc22f commit 5dea481
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Signum.React/Filters/SignumExceptionFilterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private HttpStatusCode GetStatus(Type type)
return HttpStatusCode.Forbidden;

if (type == typeof(AuthenticationException))
return HttpStatusCode.Unauthorized;
return HttpStatusCode.Forbidden; // Unauthorized produces Login Password dialog in Mixed mode

if (type == typeof(EntityNotFoundException))
return HttpStatusCode.NotFound;
Expand Down
4 changes: 3 additions & 1 deletion Signum.React/Scripts/Frames/FrameModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ export default class FrameModal extends React.Component<FrameModalProps, FrameMo

const pack = this.state.pack;

var settings = pack && Navigator.getSettings(pack.entity.Type);

return (
<Modal size={this.props.modalSize || "lg"} show={this.state.show} onExited={this.handleOnExited} onHide={this.handleCancelClicked} className="sf-popup-control" >
<Modal size={this.props.modalSize || settings && settings.modalSize || "lg"} show={this.state.show} onExited={this.handleOnExited} onHide={this.handleCancelClicked} className="sf-popup-control" >
<ModalHeaderButtons
onClose={this.props.isNavigate ? this.handleCancelClicked : undefined}
onOk={!this.props.isNavigate ? this.handleOkClicked : undefined}
Expand Down
9 changes: 6 additions & 3 deletions Signum.React/Scripts/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -645,16 +645,17 @@ export function createInNewTab(pack: EntityPack<ModifiableEntity>) {
var win = window.open(url);
}

export function createNavigateOrTab(pack: EntityPack<Entity>, event: React.MouseEvent<any>) {
export function createNavigateOrTab(pack: EntityPack<Entity>, event: React.MouseEvent<any>) : Promise<void> {
if (!pack || !pack.entity)
return;
return Promise.resolve();

const es = getSettings(pack.entity.Type);
if (es && es.avoidPopup || event.ctrlKey || event.button == 1) {
createInNewTab(pack);
return Promise.resolve();
}
else {
navigate(pack);
return navigate(pack);
}
}

Expand Down Expand Up @@ -778,6 +779,7 @@ export interface EntitySettingsOptions<T extends ModifiableEntity> {
isNavigable?: EntityWhen;
isReadOnly?: boolean;
avoidPopup?: boolean;
modalSize?: BsSize;
autocomplete?: AutocompleteConfig<any>;
autocompleteDelay?: number;
getViewPromise?: (entity: T) => ViewPromise<T>;
Expand All @@ -796,6 +798,7 @@ export class EntitySettings<T extends ModifiableEntity> {
typeName: string;

avoidPopup!: boolean;
modalSize?: BsSize;

getViewPromise?: (entity: T) => ViewPromise<T>;

Expand Down
3 changes: 1 addition & 2 deletions Signum.React/Scripts/Operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,9 @@ export class EntityOperationContext<T extends Entity> {
complete() {
var s = this.settings;
this.color = s && s.color || Defaults.getColor(this.operationInfo);
this.group = s && s.group && s.group !== undefined ? (s.group || undefined) : Defaults.getGroup(this.operationInfo);
this.group = s && s.group !== undefined ? (s.group || undefined) : Defaults.getGroup(this.operationInfo);
this.keyboardShortcut = s && s.keyboardShortcut !== undefined ? (s.keyboardShortcut || undefined) : Defaults.getKeyboardShortcut(this.operationInfo);
this.alternatives = s && s.alternatives != null ? s.alternatives(this) : Defaults.getAlternatives(this);

}

defaultClick(...args: any[]) {
Expand Down
9 changes: 6 additions & 3 deletions Signum.React/Scripts/Operations/ContextualOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ function defaultConstructFromMany(coc: ContextualOperationContext<Entity>, ...ar
return;

API.constructFromMany<Entity, Entity>(coc.context.lites, coc.operationInfo.key, ...args).then(pack => {
Navigator.createNavigateOrTab(pack, coc.event!);
Navigator.createNavigateOrTab(pack, coc.event!)
.then(() => coc.context.markRows({}))
.done();
}).done();
}).done();

Expand Down Expand Up @@ -263,8 +265,9 @@ export function defaultContextualClick(coc: ContextualOperationContext<any>, ...
API.constructFromLite(coc.context.lites[0], coc.operationInfo.key, ...args)
.then(coc.onConstructFromSuccess || (pack => {
notifySuccess();
coc.context.markRows({});
Navigator.createNavigateOrTab(pack, coc.event!);
Navigator.createNavigateOrTab(pack, coc.event!)
.then(() => coc.context.markRows({}))
.done();
}))
.done();
} else {
Expand Down
2 changes: 2 additions & 0 deletions Signum.React/Scripts/SearchControl/ContextualItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryDescription, } from '../FindOptions'
import { Lite, Entity } from '../Signum.Entities'
import SearchControlLoaded from "./SearchControlLoaded";
import { DropdownItem } from '../Components';
import { StyleContext } from '../TypeContext';

export interface MenuItemBlock {
header: string;
Expand All @@ -14,6 +15,7 @@ export interface ContextualItemsContext<T extends Entity> {
queryDescription: QueryDescription;
markRows: (dictionary: MarkedRowsDictionary) => void;
container?: SearchControlLoaded | React.Component<any, any>;
styleContext?: StyleContext;
}

export interface MarkedRowsDictionary {
Expand Down
5 changes: 4 additions & 1 deletion Signum.React/Scripts/SearchControl/SearchControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SearchControlLoaded, { ShowBarExtensionOption } from './SearchControlLoad
import { ErrorBoundary } from '../Components';
import { MaxHeightProperty } from 'csstype';
import "./Search.css"
import { ButtonBarElement } from '../TypeContext';
import { ButtonBarElement, StyleContext } from '../TypeContext';

export interface SimpleFilterBuilderProps {
findOptions: FindOptions;
Expand Down Expand Up @@ -57,6 +57,7 @@ export interface SearchControlProps extends React.Props<SearchControl> {
onSearch?: (fo: FindOptionsParsed, dataChange: boolean) => void;
onResult?: (table: ResultTable, dataChange: boolean) => void;
onCreate?: () => void;
styleContext?: StyleContext;
}

export interface SearchControlState {
Expand Down Expand Up @@ -220,6 +221,8 @@ export default class SearchControl extends React.Component<SearchControlProps, S
onFiltersChanged={p.onFiltersChanged}
onHeighChanged={p.onHeighChanged}
onResult={p.onResult}

styleContext={p.styleContext}
/>
</ErrorBoundary>
);
Expand Down
4 changes: 3 additions & 1 deletion Signum.React/Scripts/SearchControl/SearchControlLoaded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import "./Search.css"
import PinnedFilterBuilder from './PinnedFilterBuilder';
import { TitleManager } from '../../Scripts/Lines/EntityBase';
import { AutoFocus } from '../Components/AutoFocus';
import { ButtonBarElement } from '../TypeContext';
import { ButtonBarElement, StyleContext } from '../TypeContext';

export interface ShowBarExtensionOption { }

Expand Down Expand Up @@ -82,6 +82,7 @@ export interface SearchControlLoadedProps {
onHeighChanged?: () => void;
onSearch?: (fo: FindOptionsParsed, dataChange: boolean) => void;
onResult?: (table: ResultTable, dataChange: boolean) => void;
styleContext?: StyleContext;
}

export interface SearchControlLoadedState {
Expand Down Expand Up @@ -744,6 +745,7 @@ export default class SearchControlLoaded extends React.Component<SearchControlLo
queryDescription: this.props.queryDescription,
markRows: this.markRows,
container: this,
styleContext: this.props.styleContext,
}))
.then(menuItems => this.setState({ currentMenuItems: menuItems }))
.done();
Expand Down

0 comments on commit 5dea481

Please sign in to comment.