@airtable/blocks/ui#ViewPickerSynced JavaScript Examples
The following examples show how to use
@airtable/blocks/ui#ViewPickerSynced.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From apps-print-records with MIT License | 6 votes |
// The toolbar contains the view picker and print button.
function Toolbar({table}) {
return (
<Box className="print-hide" padding={2} borderBottom="thick" display="flex">
<ViewPickerSynced table={table} globalConfigKey={GlobalConfigKeys.VIEW_ID} />
<Button
onClick={() => {
// Inject CSS to hide elements with the "print-hide" class name
// when the app gets printed. This lets us hide the toolbar from
// the print output.
printWithoutElementsWithClass('print-hide');
}}
marginLeft={2}
>
Print
</Button>
</Box>
);
}
Example #2
Source File: index.js From apps-simple-chart with MIT License | 6 votes |
function Settings({table}) {
return (
<Box display="flex" padding={3} borderBottom="thick">
<FormField label="Table" width="33.33%" paddingRight={1} marginBottom={0}>
<TablePickerSynced globalConfigKey={GlobalConfigKeys.TABLE_ID} />
</FormField>
{table && (
<FormField label="View" width="33.33%" paddingX={1} marginBottom={0}>
<ViewPickerSynced table={table} globalConfigKey={GlobalConfigKeys.VIEW_ID} />
</FormField>
)}
{table && (
<FormField label="X-axis field" width="33.33%" paddingLeft={1} marginBottom={0}>
<FieldPickerSynced
table={table}
globalConfigKey={GlobalConfigKeys.X_FIELD_ID}
/>
</FormField>
)}
</Box>
);
}
Example #3
Source File: SettingsForm.js From apps-flashcard with MIT License | 5 votes |
export default function SettingsForm({setIsSettingsVisible, settings}) {
return (
<Box
flex="none"
display="flex"
flexDirection="column"
width="300px"
backgroundColor="white"
maxHeight="100vh"
borderLeft="thick"
>
<Box
flex="auto"
display="flex"
flexDirection="column"
minHeight="0"
padding={3}
overflowY="auto"
>
<Heading marginBottom={3}>Settings</Heading>
<FormField label="Table">
<TablePickerSynced globalConfigKey={ConfigKeys.TABLE_ID} />
</FormField>
{settings.table && (
<Fragment>
<FormField
label="View"
description="Only records in this view will be used"
>
<ViewPickerSynced
table={settings.table}
globalConfigKey={ConfigKeys.VIEW_ID}
/>
</FormField>
<FormField label="Question field">
<FieldPickerSynced
table={settings.table}
globalConfigKey={ConfigKeys.QUESTION_FIELD_ID}
/>
</FormField>
<FormField label="Answer field (optional)">
<FieldPickerSynced
table={settings.table}
shouldAllowPickingNone={true}
globalConfigKey={ConfigKeys.ANSWER_FIELD_ID}
/>
</FormField>
</Fragment>
)}
</Box>
<Box
flex="none"
display="flex"
justifyContent="flex-end"
paddingY={3}
marginX={3}
borderTop="thick"
>
<Button variant="primary" size="large" onClick={() => setIsSettingsVisible(false)}>
Done
</Button>
</Box>
</Box>
);
}
Example #4
Source File: todo-app.js From apps-todo-list with MIT License | 5 votes |
export default function TodoApp() {
const base = useBase();
// Read the user's choice for which table and view to use from globalConfig.
const globalConfig = useGlobalConfig();
const tableId = globalConfig.get('selectedTableId');
const viewId = globalConfig.get('selectedViewId');
const doneFieldId = globalConfig.get('selectedDoneFieldId');
const table = base.getTableByIdIfExists(tableId);
const view = table ? table.getViewByIdIfExists(viewId) : null;
const doneField = table ? table.getFieldByIdIfExists(doneFieldId) : null;
// Don't need to fetch records if doneField doesn't exist (the field or it's parent table may
// have been deleted, or may not have been selected yet.)
const records = useRecords(doneField ? view : null, {
fields: doneField ? [table.primaryField, doneField] : [],
});
const tasks = records
? records.map(record => {
return <Task key={record.id} record={record} table={table} doneField={doneField} />;
})
: null;
return (
<div>
<Box padding={3} borderBottom="thick">
<FormField label="Table">
<TablePickerSynced globalConfigKey="selectedTableId" />
</FormField>
<FormField label="View">
<ViewPickerSynced table={table} globalConfigKey="selectedViewId" />
</FormField>
<FormField label="Field" marginBottom={0}>
<FieldPickerSynced
table={table}
globalConfigKey="selectedDoneFieldId"
placeholder="Pick a 'done' field..."
allowedTypes={[FieldType.CHECKBOX]}
/>
</FormField>
</Box>
{tasks}
{table && doneField && <AddTaskForm table={table} />}
</div>
);
}