mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
R: Remove redundant checks
This commit is contained in:
parent
e96ce964ca
commit
f5087241a3
|
@ -63,15 +63,16 @@ interface RefsInputInputProps
|
||||||
| 'onBlur'
|
| 'onBlur'
|
||||||
| 'placeholder'
|
| 'placeholder'
|
||||||
> {
|
> {
|
||||||
label?: string;
|
|
||||||
onChange?: (newValue: string) => void;
|
|
||||||
schema?: IRSForm;
|
|
||||||
onOpenEdit?: (cstID: ConstituentaID) => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
|
|
||||||
initialValue?: string;
|
|
||||||
value?: string;
|
value?: string;
|
||||||
resolved?: string;
|
resolved?: string;
|
||||||
|
onChange?: (newValue: string) => void;
|
||||||
|
|
||||||
|
schema: IRSForm;
|
||||||
|
onOpenEdit?: (cstID: ConstituentaID) => void;
|
||||||
|
|
||||||
|
label?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
initialValue?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RefsInput = forwardRef<ReactCodeMirrorRef, RefsInputInputProps>(
|
const RefsInput = forwardRef<ReactCodeMirrorRef, RefsInputInputProps>(
|
||||||
|
@ -130,8 +131,8 @@ const RefsInput = forwardRef<ReactCodeMirrorRef, RefsInputInputProps>(
|
||||||
EditorView.lineWrapping,
|
EditorView.lineWrapping,
|
||||||
EditorView.contentAttributes.of({ spellcheck: 'true' }),
|
EditorView.contentAttributes.of({ spellcheck: 'true' }),
|
||||||
NaturalLanguage,
|
NaturalLanguage,
|
||||||
...(!schema || !onOpenEdit ? [] : [refsNavigation(schema, onOpenEdit)]),
|
...(!onOpenEdit ? [] : [refsNavigation(schema, onOpenEdit)]),
|
||||||
...(schema ? [refsHoverTooltip(schema, onOpenEdit !== undefined)] : [])
|
refsHoverTooltip(schema, onOpenEdit !== undefined)
|
||||||
];
|
];
|
||||||
|
|
||||||
function handleChange(newValue: string) {
|
function handleChange(newValue: string) {
|
||||||
|
@ -149,7 +150,7 @@ const RefsInput = forwardRef<ReactCodeMirrorRef, RefsInputInputProps>(
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInput(event: React.KeyboardEvent<HTMLDivElement>) {
|
function handleInput(event: React.KeyboardEvent<HTMLDivElement>) {
|
||||||
if (!thisRef.current?.view || !schema) {
|
if (!thisRef.current?.view) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -242,7 +242,7 @@ export function getDefinitionPrefix(cst: IConstituenta): string {
|
||||||
*/
|
*/
|
||||||
export function generateAlias(type: CstType, schema: IRSForm, takenAliases: string[] = []): string {
|
export function generateAlias(type: CstType, schema: IRSForm, takenAliases: string[] = []): string {
|
||||||
const prefix = getCstTypePrefix(type);
|
const prefix = getCstTypePrefix(type);
|
||||||
if (!schema.items || schema.items.length <= 0) {
|
if (schema.items.length <= 0) {
|
||||||
return `${prefix}1`;
|
return `${prefix}1`;
|
||||||
}
|
}
|
||||||
let index = schema.items.reduce((prev, cst, index) => {
|
let index = schema.items.reduce((prev, cst, index) => {
|
||||||
|
|
|
@ -49,7 +49,7 @@ function EditorOssCard() {
|
||||||
<EditorLibraryItem controller={controller} />
|
<EditorLibraryItem controller={controller} />
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
|
|
||||||
{controller.schema ? <OssStats stats={controller.schema.stats} /> : null}
|
<OssStats stats={controller.schema.stats} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -70,9 +70,6 @@ function FormOSS({ id }: FormOSSProps) {
|
||||||
if (event) {
|
if (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
if (!schema) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const data: IUpdateLibraryItemDTO = {
|
const data: IUpdateLibraryItemDTO = {
|
||||||
id: schema.id,
|
id: schema.id,
|
||||||
item_type: LibraryItemType.RSFORM,
|
item_type: LibraryItemType.RSFORM,
|
||||||
|
|
|
@ -120,9 +120,6 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren<OssEd
|
||||||
);
|
);
|
||||||
|
|
||||||
function navigateTab(tab: OssTabID) {
|
function navigateTab(tab: OssTabID) {
|
||||||
if (!schema) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const url = urls.oss_props({
|
const url = urls.oss_props({
|
||||||
id: schema.id,
|
id: schema.id,
|
||||||
tab: tab
|
tab: tab
|
||||||
|
|
|
@ -48,7 +48,7 @@ function EditorRSFormCard() {
|
||||||
<EditorLibraryItem controller={controller} />
|
<EditorLibraryItem controller={controller} />
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
|
|
||||||
{controller.schema ? <RSFormStats stats={controller.schema.stats} isArchive={controller.isArchive} /> : null}
|
<RSFormStats stats={controller.schema.stats} isArchive={controller.isArchive} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -80,9 +80,6 @@ function FormRSForm({ id }: FormRSFormProps) {
|
||||||
if (event) {
|
if (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
if (!schema) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const data: IUpdateLibraryItemDTO = {
|
const data: IUpdateLibraryItemDTO = {
|
||||||
id: schema.id,
|
id: schema.id,
|
||||||
item_type: LibraryItemType.RSFORM,
|
item_type: LibraryItemType.RSFORM,
|
||||||
|
|
|
@ -139,9 +139,6 @@ export const RSEditState = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateRSForm({ tab, activeID }: { tab: RSTabID; activeID?: ConstituentaID }) {
|
function navigateRSForm({ tab, activeID }: { tab: RSTabID; activeID?: ConstituentaID }) {
|
||||||
if (!schema) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const data = {
|
const data = {
|
||||||
id: schema.id,
|
id: schema.id,
|
||||||
tab: tab,
|
tab: tab,
|
||||||
|
@ -170,7 +167,7 @@ export const RSEditState = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSchema() {
|
function deleteSchema() {
|
||||||
if (!schema || !window.confirm(prompts.deleteLibraryItem)) {
|
if (!window.confirm(prompts.deleteLibraryItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ossID = schema.oss.length > 0 ? schema.oss[0].id : undefined;
|
const ossID = schema.oss.length > 0 ? schema.oss[0].id : undefined;
|
||||||
|
@ -227,7 +224,7 @@ export const RSEditState = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveUp() {
|
function moveUp() {
|
||||||
if (!schema.items || selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentIndex = schema.items.reduce((prev, cst, index) => {
|
const currentIndex = schema.items.reduce((prev, cst, index) => {
|
||||||
|
@ -249,7 +246,7 @@ export const RSEditState = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveDown() {
|
function moveDown() {
|
||||||
if (!schema.items || selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user