mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: enable create card from header button
This commit is contained in:
@ -14,6 +14,9 @@ pub struct CreateBoardCardPayloadPB {
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub group_id: String,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub start_row_id: Option<String>,
|
||||
}
|
||||
|
||||
impl TryInto<CreateRowParams> for CreateBoardCardPayloadPB {
|
||||
@ -22,9 +25,13 @@ impl TryInto<CreateRowParams> for CreateBoardCardPayloadPB {
|
||||
fn try_into(self) -> Result<CreateRowParams, Self::Error> {
|
||||
let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
|
||||
let group_id = NotEmptyStr::parse(self.group_id).map_err(|_| ErrorCode::GroupIdIsEmpty)?;
|
||||
let start_row_id = match self.start_row_id {
|
||||
None => None,
|
||||
Some(start_row_id) => Some(NotEmptyStr::parse(start_row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?.0),
|
||||
};
|
||||
Ok(CreateRowParams {
|
||||
grid_id: grid_id.0,
|
||||
start_row_id: None,
|
||||
start_row_id,
|
||||
group_id: Some(group_id.0),
|
||||
layout: GridLayout::Board,
|
||||
})
|
||||
|
@ -95,9 +95,13 @@ impl GridViewRevisionEditor {
|
||||
match params.group_id.as_ref() {
|
||||
None => {}
|
||||
Some(group_id) => {
|
||||
let index = match params.start_row_id {
|
||||
None => Some(0),
|
||||
Some(_) => None,
|
||||
};
|
||||
let inserted_row = InsertedRowPB {
|
||||
row: row_pb.clone(),
|
||||
index: None,
|
||||
index,
|
||||
is_new: true,
|
||||
};
|
||||
let changeset = GroupChangesetPB::insert(group_id.clone(), vec![inserted_row]);
|
||||
|
Reference in New Issue
Block a user