talbe definition web
This commit is contained in:
@@ -27,7 +27,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
loader::load_page,
|
||||
loader::{self, load_page},
|
||||
state::{
|
||||
CopyForm, DeleteForm, GeneratedTableView, InvoiceTemplateForm, LoadError, PageInputs,
|
||||
RenameForm, Selection,
|
||||
@@ -73,8 +73,16 @@ pub(crate) async fn update_columns(
|
||||
return rejection;
|
||||
}
|
||||
|
||||
// Staging a column applies the vocabulary's rules, so it is read before
|
||||
// the panel is rebuilt; `load_page` reuses what is read here.
|
||||
let mut definitions = state.definitions.clone();
|
||||
let catalog = match loader::load_column_catalog(&mut definitions, &headers).await {
|
||||
Ok(catalog) => catalog,
|
||||
Err(error) => return load_error_response(error),
|
||||
};
|
||||
|
||||
let mut inputs = PageInputs::for_selection(selection);
|
||||
inputs.columns = form.to_draft(false);
|
||||
inputs.columns = form.to_draft(catalog, false);
|
||||
|
||||
let index = form.index.unwrap_or(0);
|
||||
match form.action.as_str() {
|
||||
@@ -108,8 +116,16 @@ pub(crate) async fn add_columns(
|
||||
return rejection;
|
||||
}
|
||||
|
||||
// The draft is validated before the write, so the vocabulary it is held to
|
||||
// is read first; `load_page` reuses what is read here.
|
||||
let mut definitions = state.definitions.clone();
|
||||
let catalog = match loader::load_column_catalog(&mut definitions, &headers).await {
|
||||
Ok(catalog) => catalog,
|
||||
Err(error) => return load_error_response(error),
|
||||
};
|
||||
|
||||
let mut inputs = PageInputs::for_selection(selection);
|
||||
inputs.columns = form.to_draft(false);
|
||||
inputs.columns = form.to_draft(catalog.clone(), false);
|
||||
|
||||
if !inputs.selection.has_table() {
|
||||
return refuse(state, headers, inputs, "Select a table first.".to_string()).await;
|
||||
@@ -139,7 +155,6 @@ pub(crate) async fn add_columns(
|
||||
return Redirect::to("/login").into_response();
|
||||
};
|
||||
|
||||
let mut definitions = state.definitions.clone();
|
||||
match definitions.add_table_columns(request).await {
|
||||
Ok(response) if response.get_ref().success => {
|
||||
let added = inputs.columns.added.len();
|
||||
@@ -150,7 +165,7 @@ pub(crate) async fn add_columns(
|
||||
inputs.selection.table
|
||||
));
|
||||
// The columns are the table's now, so the panel starts empty.
|
||||
inputs.columns = crate::schema::ColumnDraft::for_append();
|
||||
inputs.columns = crate::schema::ColumnDraft::for_append(catalog);
|
||||
respond(state, headers, inputs, StatusCode::OK).await
|
||||
}
|
||||
Ok(response) => {
|
||||
|
||||
Reference in New Issue
Block a user