From 9d06a34df4faf01375370c90997095d2c8b18a71 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Thu, 22 Jun 2023 12:49:53 +0200 Subject: [PATCH] :bug: Fix Annotation is not shown on View mode --- .../src/app/common/types/components_list.cljc | 6 ++++ .../data/workspace/annotation_helpers.cljs | 28 ------------------- .../main/ui/viewer/inspect/attributes.cljs | 6 ++-- 3 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 frontend/src/app/main/data/workspace/annotation_helpers.cljs diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index d5d37267ed..1dd2917709 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -115,3 +115,9 @@ [] [[(:id shape) (:component-id shape) :component]])) [])) + +(defn get-component-annotation + [shape libraries] + (let [library (dm/get-in libraries [(:component-file shape) :data]) + component (get-component library (:component-id shape) true)] + (:annotation component))) diff --git a/frontend/src/app/main/data/workspace/annotation_helpers.cljs b/frontend/src/app/main/data/workspace/annotation_helpers.cljs deleted file mode 100644 index a0b00956a6..0000000000 --- a/frontend/src/app/main/data/workspace/annotation_helpers.cljs +++ /dev/null @@ -1,28 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.main.data.workspace.annotation-helpers - (:require - [app.common.data.macros :as dm] - [app.common.logging :as log] - [app.common.types.components-list :as ctkl] - [app.main.refs :as refs])) - -;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default -(log/set-level! :warn) - - -(defn get-main-annotation - [shape libraries] - (let [library (dm/get-in libraries [(:component-file shape) :data]) - component (ctkl/get-component library (:component-id shape) true)] - (:annotation component))) - -(defn get-main-annotation-viewer - [shape libraries] - (let [objects (deref (refs/get-viewer-objects)) - parent (get objects (:parent-id shape))] - (get-main-annotation parent libraries))) diff --git a/frontend/src/app/main/ui/viewer/inspect/attributes.cljs b/frontend/src/app/main/ui/viewer/inspect/attributes.cljs index 50b2e1b092..997b83a6c0 100644 --- a/frontend/src/app/main/ui/viewer/inspect/attributes.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/attributes.cljs @@ -7,7 +7,7 @@ (ns app.main.ui.viewer.inspect.attributes (:require [app.common.geom.shapes :as gsh] - [app.main.data.workspace.annotation-helpers :as dwah] + [app.common.types.components-list :as ctkl] [app.main.ui.hooks :as hooks] [app.main.ui.viewer.inspect.annotation :refer [annotation]] [app.main.ui.viewer.inspect.attributes.blur :refer [blur-panel]] @@ -41,9 +41,7 @@ type (if (= (count shapes) 1) (-> shapes first :type) :multiple) options (type->options type) content (when (= (count shapes) 1) - (if (= from :workspace) - (dwah/get-main-annotation (first shapes) libraries) - (dwah/get-main-annotation-viewer (first shapes) libraries)))] + (ctkl/get-component-annotation (first shapes) libraries))] [:div.element-options (for [[idx option] (map-indexed vector options)]