Skip to content

Commit

Permalink
using components for files locked state
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed Feb 5, 2025
1 parent ab6c212 commit 8edacac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions oarepo_ui/resources/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .communities import AllowedCommunitiesComponent
from .files import FilesComponent
from .permissions import PermissionsComponent
from .files_locked import FilesLockedComponent

__all__ = (
"UIResourceComponent",
Expand All @@ -12,4 +13,5 @@
"BabelComponent",
"FilesComponent",
"AllowedCommunitiesComponent",
"FilesLockedComponent",
)
34 changes: 34 additions & 0 deletions oarepo_ui/resources/components/files_locked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from .base import UIResourceComponent
from typing import Dict
from flask_principal import Identity


class FilesLockedComponent(UIResourceComponent):
"""Add files locked to form config, to be able to use the same logic as in RDM"""
def before_ui_create(
self,
*,
data: Dict,
identity: Identity,
form_config: Dict,
args: Dict,
view_args: Dict,
ui_links: Dict,
extra_context: Dict,
**kwargs,
) -> None:
form_config["filesLocked"] = False

def before_ui_edit(
self,
*,
data: Dict,
identity: Identity,
form_config: Dict,
args: Dict,
view_args: Dict,
ui_links: Dict,
extra_context: Dict,
**kwargs,
) -> None:
form_config["filesLocked"] = True
2 changes: 0 additions & 2 deletions oarepo_ui/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ def edit(self):
)

form_config["ui_model"] = self.ui_model
form_config["filesLocked"] = True

ui_links = self.expand_detail_links(identity=g.identity, record=api_record)

Expand Down Expand Up @@ -594,7 +593,6 @@ def create(self):
)

form_config["ui_model"] = self.ui_model
form_config["filesLocked"] = False

extra_context = dict()

Expand Down

0 comments on commit 8edacac

Please sign in to comment.