-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put tags in asset, remove sprite & audio doc
- Loading branch information
Showing
10 changed files
with
108 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
luda-editor/new-server/database/schema/0/src/asset/sprite/mod.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::*; | ||
|
||
#[doc_part] | ||
#[derive(Copy, PartialEq, Eq, Hash)] | ||
#[archive_attr(derive(PartialEq, Eq, Hash))] | ||
#[repr(u8)] | ||
enum AssetSystemTag { | ||
// Sprite 0 ~ 39 | ||
SpriteCharacter = 0, | ||
SpriteObject = 1, | ||
SpriteBackground = 2, | ||
// Audio 40 ~ 79 | ||
AudioCharacter = 40, | ||
AudioProp = 41, | ||
AudioBackground = 42, | ||
} | ||
|
||
#[document] | ||
struct AssetCustomTagDoc { | ||
#[pk] | ||
id: String, | ||
names: Translations, | ||
} | ||
|
||
#[doc_part] | ||
#[derive(PartialEq, Eq, Hash)] | ||
#[archive_attr(derive(PartialEq, Eq, Hash))] | ||
enum AssetTag { | ||
System { tag: AssetSystemTag }, | ||
Custom { id: String }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
luda-editor/new-server/server/src/api/asset/update_asset_tags_for_asset/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::*; | ||
use api::team::is_team_member; | ||
use database::{schema::*, DeserializeInfallible, WantUpdate}; | ||
use luda_rpc::asset::update_asset_tags_for_asset::*; | ||
|
||
pub async fn update_asset_tags_for_asset( | ||
ArchivedRequest { asset_id, tags }: &ArchivedRequest, | ||
db: &Database, | ||
session: Session, | ||
) -> Result<Response> { | ||
let user_id = session.user_id().await.ok_or(Error::NeedLogin)?; | ||
|
||
let asset_team_doc = db | ||
.get(AssetTeamDocGet { asset_id }) | ||
.await? | ||
.ok_or(Error::AssetNotExist)?; | ||
|
||
if !is_team_member(db, &asset_team_doc.team_id, &user_id).await? { | ||
bail!(Error::PermissionDenied) | ||
} | ||
|
||
db.transact::<()>(AssetDocUpdate { | ||
id: asset_id, | ||
want_update: |_| WantUpdate::Yes, | ||
update: |doc| { | ||
doc.tags = tags.iter().map(|x| x.deserialize()).collect(); | ||
}, | ||
}) | ||
.await? | ||
.unwrap(); | ||
|
||
Ok(Response {}) | ||
} |