Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed May 13, 2020
2 parents ec4ab65 + 7a644ca commit 75db6b6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 13 deletions.
9 changes: 7 additions & 2 deletions Signum.React/Scripts/Components/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ export default function TextArea(p: TextAreaProps) {
}, [innerRef, minHeight]);

return (
<textarea onInput={autoResize ? (e => handleResize(e.currentTarget)) : undefined} style={
<textarea {...props} onInput={e => {
if (p.autoResize)
handleResize(e.currentTarget);
if (p.onInput)
p.onInput(e);
}} style={
{
...(autoResize ? { display: "block", overflow: "hidden", resize: "none" } : {}),
...props.style
}
} {...props} ref={handleRef} />
} ref={handleRef} />
);
}

Expand Down
12 changes: 8 additions & 4 deletions Signum.React/Scripts/Frames/Notify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ interface NotifyOptions {
}

interface NotifyHandle {
notify(options: NotifyOptions) : void;
notifyTimeout(options: NotifyOptions, timeout?: number): void
notify(options: NotifyOptions): NotifyOptions;
notifyTimeout(options: NotifyOptions, timeout?: number): NotifyOptions
notifyPendingRequest(pending: number): void;
remove(options: NotifyOptions): void;
}

export default function Notify() {
Expand All @@ -39,12 +40,14 @@ export default function Notify() {
optionsStack.current.extract(a => a == options);
optionsStack.current.push(options);
forceUpdate();
return options;
}

function notifyTimeout(options: NotifyOptions, timeout: number = 2000) {
function notifyTimeout(options: NotifyOptions, timeout: number = 2000): NotifyOptions {
notify(options);

options.timeoutHandler = setTimeout(() => remove(options), timeout);
return options;
}

const loadingRef = React.useRef<NotifyOptions>({ text: JavascriptMessage.loading.niceToString(), type: "loading", priority: 0 });
Expand All @@ -69,7 +72,8 @@ export default function Notify() {
Notify.singleton = {
notify: notify,
notifyTimeout: notifyTimeout,
notifyPendingRequest: notifyPendingRequest
notifyPendingRequest: notifyPendingRequest,
remove: remove,
};

return () => Notify.singleton = undefined;
Expand Down
2 changes: 0 additions & 2 deletions Signum.React/Scripts/Globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,6 @@ String.prototype.tryAfterLast = function (this: string, separator: string) {
String.prototype.etc = function (this: string, maxLength: number, etcString: string = "(…)") {
let str = this;

str = str.tryBefore("\n") || str;

if (str.length > maxLength)
str = str.substr(0, maxLength - etcString.length) + etcString;

Expand Down
3 changes: 2 additions & 1 deletion Signum.React/Scripts/Lines/AutoCompleteConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export class FindOptionsAutocompleteConfig implements AutocompleteConfig<ResultR

var filters = [...fo.filterOptions ?? []];

if (fo.includeDefaultFilters ?? true) {
/*When overriden in Finder very often uses not seen columns (like Telephone) that are not seen in autocomplete, better to use false by default and you can opt-in by adding includeDefaultFilters if needed */
if (fo.includeDefaultFilters ?? false) {
var defaultFilters = Finder.getDefaultFilter(qd, qs);
if (defaultFilters)
filters = [...defaultFilters, ...filters];
Expand Down
2 changes: 1 addition & 1 deletion Signum.React/Scripts/Operations/EntityOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function andNew<T extends Entity>(eoc: EntityOperationContext<T>, inDropd
Navigator.getSettings(pack.entity.Type)?.onCreateNew ??
(pack => Constructor.constructPack(pack.entity.Type));

createNew(pack)
(createNew(pack) ?? Promise.resolve(undefined))
.then(newPack => newPack && eoc.frame.onReload(newPack, true))
.done();
};
Expand Down
7 changes: 5 additions & 2 deletions Signum.React/Scripts/SearchControl/EntityLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ export default function EntityLink(p: EntityLinkProps) {
innerRef={p.innerRef as any}
to={Navigator.navigateRoute(lite)}
title={StyleContext.default.titleLabels ? p.title ?? getToString(lite) : undefined}
onClick={handleClick}
data-entity={liteKey(lite)}
{...(htmlAtts as React.HTMLAttributes<HTMLAnchorElement>)}>
{...(htmlAtts as React.HTMLAttributes<HTMLAnchorElement>)}
onClick={handleClick}
>
{children ?? lite.toStr}
</Link>
);

function handleClick(event: React.MouseEvent<any>) {

event.preventDefault();
p.onClick?.call(event.currentTarget, event);

const lite = p.lite;
const s = Navigator.getSettings(lite.EntityType)
const avoidPopup = s != undefined && s.avoidPopup;
Expand Down
2 changes: 1 addition & 1 deletion Signum.React/Scripts/SearchControl/SearchControlLoaded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export default class SearchControlLoaded extends React.Component<SearchControlLo
order: -5,
button: <button
className={classes("sf-query-button sf-filters-header btn", s.showFilters && "active", "btn-light")}
style={!s.showFilters && p.findOptions.filterOptions.filter(a => !a.pinned).length > 0 ? { border: "1px solid black" } : undefined}
style={!s.showFilters && p.findOptions.filterOptions.filter(a => !a.pinned).length > 0 ? { border: "1px solid #6c757d" } : undefined}
onClick={this.handleToggleFilters}
title={titleLabels ? s.showFilters ? JavascriptMessage.hideFilters.niceToString() : JavascriptMessage.showFilters.niceToString() : undefined}>
<FontAwesomeIcon icon="filter" />
Expand Down
12 changes: 12 additions & 0 deletions Signum.React/Scripts/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface AjaxOptions {
url: string;
avoidNotifyPendingRequests?: boolean;
avoidThrowError?: boolean;
avoidRetry?: boolean;
avoidGraphExplorer?: boolean;
avoidAuthToken?: boolean;
avoidVersionCheck?: boolean;
Expand Down Expand Up @@ -103,6 +104,11 @@ export function wrapRequest(options: AjaxOptions, makeCall: () => Promise<Respon
addContextHeaders.forEach(f => f(options));
}

if (!options.avoidRetry) {
const call = makeCall;
makeCall = () => RetryFilter.retryFilter(call);
}

if (!options.avoidVersionCheck) {
const call = makeCall;
makeCall = () => VersionFilter.onVersionFilter(call);
Expand Down Expand Up @@ -132,6 +138,12 @@ export function wrapRequest(options: AjaxOptions, makeCall: () => Promise<Respon

}

export module RetryFilter {
export function retryFilter(makeCall: () => Promise<Response>): Promise<Response>{
return makeCall();
}
}

export module AuthTokenFilter {
export let addAuthToken: (options: AjaxOptions, makeCall: () => Promise<Response>) => Promise<Response>;
}
Expand Down

0 comments on commit 75db6b6

Please sign in to comment.