django-spire 0.25.1__py3-none-any.whl → 0.26.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_spire/ai/chat/router.py +10 -20
- django_spire/ai/chat/templates/django_spire/ai/chat/dropdown/ellipsis_dropdown.html +5 -3
- django_spire/ai/chat/templates/django_spire/ai/chat/message/default_message.html +6 -2
- django_spire/ai/chat/templatetags/spire_ai_chat_tags.py +19 -0
- django_spire/ai/chat/tests/test_router/test_spire_chat_router.py +20 -88
- django_spire/auth/templates/django_spire/auth/element/android_and_chrome_app_install_element.html +33 -0
- django_spire/auth/templates/django_spire/auth/element/ios_app_install_element.html +48 -0
- django_spire/auth/templates/django_spire/auth/page/auth_page.html +2 -1
- django_spire/auth/templates/django_spire/auth/page/login_page.html +2 -0
- django_spire/comment/mixins.py +3 -3
- django_spire/comment/templates/django_spire/comment/card/comment_list_card.html +8 -5
- django_spire/comment/templates/django_spire/comment/form/comment_form.html +3 -3
- django_spire/comment/templates/django_spire/comment/form/content/comment_form_content.html +1 -0
- django_spire/comment/templates/django_spire/comment/item/comment_item_ellipsis.html +12 -8
- django_spire/comment/views.py +8 -8
- django_spire/consts.py +1 -1
- django_spire/contrib/form/utils.py +3 -3
- django_spire/contrib/progress/session.py +1 -1
- django_spire/contrib/queryset/filter_tools.py +56 -14
- django_spire/contrib/queryset/mixins.py +24 -3
- django_spire/contrib/service/django_model_service.py +5 -6
- django_spire/core/management/commands/spire_startapp.py +42 -25
- django_spire/core/management/commands/spire_startapp_pkg/exceptions.py +5 -0
- django_spire/core/management/commands/spire_startapp_pkg/maps.py +64 -32
- django_spire/core/management/commands/spire_startapp_pkg/template/app/constants.py.template +1 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/app/forms.py.template +4 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/app/models.py.template +2 -1
- django_spire/core/management/commands/spire_startapp_pkg/template/app/querysets.py.template +15 -6
- django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/__init__.py.template +1 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/form_urls.py.template +6 -6
- django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/page_urls.py.template +2 -2
- django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/template_urls.py.template +12 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/app/views/form_views.py.template +10 -11
- django_spire/core/management/commands/spire_startapp_pkg/template/app/views/page_views.py.template +17 -3
- django_spire/core/management/commands/spire_startapp_pkg/template/app/views/template_views.py.template +40 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${form_card_template_name}.html.template +1 -1
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_base_card_template_name}.html.template +16 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_items_card_template_name}.html.template +16 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_table_card_template_name}.html.template +16 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/container/${list_container_template_name}.html.template +1 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/form/${list_filter_form_template_name}.html.template +30 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/${item_template_name}.html.template +32 -20
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/${list_items_template_name}.html.template +3 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/${detail_page_template_name}.html.template +3 -3
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/${form_page_template_name}.html.template +2 -2
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/${list_page_template_name}.html.template +2 -2
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/table/${table_row_template_name}.html.template +6 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/table/${table_rows_template_name}.html.template +3 -0
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/table/${table_template_name}.html.template +6 -0
- django_spire/core/management/commands/spire_startapp_pkg/user_input.py +82 -9
- django_spire/core/management/commands/spire_startapp_pkg/validator.py +19 -6
- django_spire/core/middleware.py +2 -3
- django_spire/core/querysets.py +19 -0
- django_spire/core/static/django_spire/js/theme.js +10 -7
- django_spire/core/templates/django_spire/badge/base_badge.html +2 -3
- django_spire/core/templates/django_spire/base/base.html +1 -0
- django_spire/core/templates/django_spire/button/base_button.html +2 -1
- django_spire/core/templates/django_spire/card/title_card.html +13 -10
- django_spire/core/templates/django_spire/container/container.html +1 -1
- django_spire/core/templates/django_spire/filtering/form/base_session_filter_form.html +1 -1
- django_spire/core/templates/django_spire/form/field/_base_file_field.html +216 -0
- django_spire/core/templates/django_spire/form/field/_multi_checkbox_field.html +52 -0
- django_spire/core/templates/django_spire/form/field/base_field.html +128 -0
- django_spire/core/templates/django_spire/form/field/char_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/color_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/date_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/datetime_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/decimal_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/element/select_checkmark_element.html +4 -0
- django_spire/core/templates/django_spire/form/field/element/select_down_arrow_element.html +5 -0
- django_spire/core/templates/django_spire/form/field/email_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/input_field.html +13 -0
- django_spire/core/templates/django_spire/form/field/item/select_choice_item.html +15 -0
- django_spire/core/templates/django_spire/form/field/item/selected_choice_item.html +5 -0
- django_spire/core/templates/django_spire/form/field/list_field.html +112 -0
- django_spire/core/templates/django_spire/form/field/multi_file_field.html +90 -0
- django_spire/core/templates/django_spire/form/field/multi_select_field.html +155 -0
- django_spire/core/templates/django_spire/form/field/number_field.html +11 -0
- django_spire/core/templates/django_spire/form/field/password_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/radio_field.html +24 -0
- django_spire/core/templates/django_spire/form/field/range_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/search_and_select_field.html +119 -0
- django_spire/core/templates/django_spire/form/field/search_field.html +5 -0
- django_spire/core/templates/django_spire/form/field/select_field.html +78 -0
- django_spire/core/templates/django_spire/form/field/single_checkbox_field.html +27 -0
- django_spire/core/templates/django_spire/form/field/single_file_field.html +90 -0
- django_spire/core/templates/django_spire/form/field/telephone_field.html +1 -0
- django_spire/core/templates/django_spire/form/field/text_field.html +11 -0
- django_spire/core/templates/django_spire/form/field/time_field.html +1 -0
- django_spire/core/templates/django_spire/infinite_scroll/base.html +2 -1
- django_spire/core/templatetags/model_tags.py +34 -0
- django_spire/knowledge/entry/forms.py +1 -1
- django_spire/knowledge/entry/models.py +18 -0
- django_spire/knowledge/entry/querysets.py +8 -6
- django_spire/knowledge/entry/services/processor_service.py +1 -0
- django_spire/knowledge/entry/services/search_index_service.py +61 -0
- django_spire/knowledge/entry/services/search_service.py +99 -0
- django_spire/knowledge/entry/services/service.py +6 -0
- django_spire/knowledge/entry/version/services/processor_service.py +2 -0
- django_spire/knowledge/entry/version/tests/factories.py +9 -4
- django_spire/knowledge/entry/version/tests/test_services.py +7 -16
- django_spire/knowledge/intelligence/bots/knowledge_answer_bot.py +40 -6
- django_spire/knowledge/intelligence/bots/knowledge_entries_bot.py +4 -2
- django_spire/knowledge/intelligence/bots/search_preprocessing_bot.py +32 -0
- django_spire/knowledge/intelligence/intel/entry_intel.py +12 -0
- django_spire/knowledge/intelligence/router.py +47 -4
- django_spire/knowledge/intelligence/workflows/knowledge_workflow.py +24 -42
- django_spire/knowledge/intelligence/workflows/search_preprocessing_workflow.py +78 -0
- django_spire/knowledge/management/__init__.py +0 -0
- django_spire/knowledge/management/commands/__init__.py +0 -0
- django_spire/knowledge/management/commands/rebuild_knowledge_search_index.py +16 -0
- django_spire/knowledge/migrations/0010_entry__search_text_entry__search_vector_and_more.py +40 -0
- django_spire/knowledge/templates/django_spire/knowledge/message/knowledge_message_intel.html +31 -23
- django_spire/metric/report/enums.py +11 -5
- django_spire/metric/report/report.py +24 -12
- django_spire/metric/report/tools.py +14 -4
- django_spire/testing/playwright/fixtures.py +4 -5
- {django_spire-0.25.1.dist-info → django_spire-0.26.0.dist-info}/METADATA +1 -1
- {django_spire-0.25.1.dist-info → django_spire-0.26.0.dist-info}/RECORD +123 -69
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_card_template_name}.html.template +0 -18
- /django_spire/{core/management/commands/spire_startapp_pkg/template/app/tests/test_intelligence/__init__.py.template → ai/chat/templatetags/__init__.py} +0 -0
- {django_spire-0.25.1.dist-info → django_spire-0.26.0.dist-info}/WHEEL +0 -0
- {django_spire-0.25.1.dist-info → django_spire-0.26.0.dist-info}/licenses/LICENSE.md +0 -0
- {django_spire-0.25.1.dist-info → django_spire-0.26.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
{# This can be removed and need to insert input fields to have getlist and get effect #}
|
|
5
|
+
<div
|
|
6
|
+
class="position-relative"
|
|
7
|
+
x-data="{
|
|
8
|
+
show_dropdown: false,
|
|
9
|
+
search: '',
|
|
10
|
+
init () {
|
|
11
|
+
this.parse_value()
|
|
12
|
+
|
|
13
|
+
this.$watch('glue_field.value', value => {
|
|
14
|
+
this.parse_value()
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
add_choice(choice) {
|
|
18
|
+
this.glue_field.value.push(choice[0])
|
|
19
|
+
},
|
|
20
|
+
get get_selected_choices() {
|
|
21
|
+
if (!Array.isArray(this.glue_field.value)) {
|
|
22
|
+
return []
|
|
23
|
+
}
|
|
24
|
+
return this.glue_field.choices.filter(choice => this.glue_field.value.includes(choice[0]))
|
|
25
|
+
},
|
|
26
|
+
get filtered_choices() {
|
|
27
|
+
if (!Array.isArray(this.glue_field.value)) {
|
|
28
|
+
return []
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const filtered_array = this.glue_field.choices.filter(choice => !this.glue_field.value.includes(choice[0]) && choice[1] !== '----------')
|
|
32
|
+
|
|
33
|
+
const search = this.search.toLowerCase()
|
|
34
|
+
return filtered_array.filter(filtered_choice => filtered_choice[1].toLowerCase().includes(search))
|
|
35
|
+
},
|
|
36
|
+
focus_input() {
|
|
37
|
+
setTimeout(() => this.$refs.search_input.focus(), 100)
|
|
38
|
+
},
|
|
39
|
+
parse_value(){
|
|
40
|
+
// It is already an array!
|
|
41
|
+
if (Array.isArray(this.glue_field.value)) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Parse the initial value into an array.
|
|
46
|
+
if (typeof(this.glue_field.value) == 'string' && this.glue_field.value.startsWith('[')){
|
|
47
|
+
value = JSON.parse(this.glue_field.value)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Must be an array.
|
|
52
|
+
this.glue_field.value = []
|
|
53
|
+
},
|
|
54
|
+
remove_choice(choice) {
|
|
55
|
+
this.glue_field.value = this.glue_field.value.filter(val => val !== choice[0])
|
|
56
|
+
},
|
|
57
|
+
}"
|
|
58
|
+
>
|
|
59
|
+
<template x-for="choice in get_selected_choices" :key="choice[0]">
|
|
60
|
+
<input hidden type="text" :name="glue_field.name" :value="choice[0]">
|
|
61
|
+
|
|
62
|
+
</template>
|
|
63
|
+
<div x-ref="inputs"></div>
|
|
64
|
+
|
|
65
|
+
{% block selected_choices %}
|
|
66
|
+
<button
|
|
67
|
+
class="form-control text-start d-flex justify-content-between"
|
|
68
|
+
type="button"
|
|
69
|
+
@click="show_dropdown = !show_dropdown; focus_input();"
|
|
70
|
+
>
|
|
71
|
+
<span class="d-flex flex-wrap align-items-center">
|
|
72
|
+
<template x-for="choice in get_selected_choices" :key="choice[0]">
|
|
73
|
+
<div class="d-inline-block my-1">
|
|
74
|
+
<span class="badge rounded-pill glue-fs--1 text-app-glue-primary fw-normal border me-1">
|
|
75
|
+
<span x-text="choice[1]"></span>
|
|
76
|
+
</span>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<template x-if="get_selected_choices.length === 0">
|
|
81
|
+
<span>----------</span>
|
|
82
|
+
</template>
|
|
83
|
+
</span>
|
|
84
|
+
|
|
85
|
+
<span class="d-flex align-items-center">
|
|
86
|
+
{% include 'django_spire/form/field/element/select_down_arrow_element.html' %}
|
|
87
|
+
</span>
|
|
88
|
+
</button>
|
|
89
|
+
{% endblock %}
|
|
90
|
+
|
|
91
|
+
<div
|
|
92
|
+
x-cloak
|
|
93
|
+
x-show="show_dropdown"
|
|
94
|
+
@click.outside="show_dropdown = false"
|
|
95
|
+
class="shadow border rounded-2 mt-2 position-absolute z-3 bg-app-glue-layer-one w-100 p-0 list-group"
|
|
96
|
+
style="max-height: 350px; overflow-y: auto; z-index: 3;"
|
|
97
|
+
@keydown.escape="show_dropdown = false"
|
|
98
|
+
x-trap.inert="show_dropdown"
|
|
99
|
+
>
|
|
100
|
+
<div class="glue-fs--2 fw-bold ms-2 my-1">
|
|
101
|
+
Select Many <span>"<span x-text="glue_field.label"></span>"</span>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div class="m-1">
|
|
105
|
+
<input
|
|
106
|
+
x-model="search"
|
|
107
|
+
class="form-control py-1 glue-fs--2"
|
|
108
|
+
placeholder="Search..."
|
|
109
|
+
type="text"
|
|
110
|
+
x-ref="search_input"
|
|
111
|
+
@keydown.enter.prevent="add_choice(filtered_choices[0])"
|
|
112
|
+
>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<template x-for="(choice, index) in get_selected_choices" :key="index">
|
|
116
|
+
<div
|
|
117
|
+
class="glue-cursor-pointer glue-user-select py-1 d-flex align-items-center list-group-item px-0 bg-app-glue-layer-one-hover"
|
|
118
|
+
tabindex="0"
|
|
119
|
+
@click="remove_choice(choice)"
|
|
120
|
+
@keydown.enter.prevent="remove_choice(choice)"
|
|
121
|
+
>
|
|
122
|
+
{% block selected_choice_item %}
|
|
123
|
+
{% include 'django_spire/form/field/item/selected_choice_item.html' %}
|
|
124
|
+
{% endblock %}
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<template x-if="get_selected_choices.length > 0 && filtered_choices.length !== 0">
|
|
129
|
+
<div>
|
|
130
|
+
<span class="d-block glue-fs--2 ms-3">Choices</span>
|
|
131
|
+
</div>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<template x-for="(choice, index) in filtered_choices" :key="choice[0]">
|
|
135
|
+
<div
|
|
136
|
+
class="glue-user-select py-1 d-flex align-items-center list-group-item px-0"
|
|
137
|
+
tabindex="0"
|
|
138
|
+
@click="glue_field.disabled_choices.includes(choice[0]) ? '' : add_choice(choice)"
|
|
139
|
+
:class="glue_field.disabled_choices.includes(choice[0]) ? 'opacity-50 glue-user-select glue-cursor-not-allowed' : 'glue-cursor-pointer bg-app-glue-layer-one-hover'"
|
|
140
|
+
@keydown.enter.prevent="add_choice(choice)"
|
|
141
|
+
>
|
|
142
|
+
{% block choice_item %}
|
|
143
|
+
{% include 'django_spire/form/field/item/select_choice_item.html' %}
|
|
144
|
+
{% endblock %}
|
|
145
|
+
</div>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<template x-if="filtered_choices.length === 0">
|
|
149
|
+
<div class="py-1">
|
|
150
|
+
<span class="d-block glue-fs--2 ms-3">No available choices</span>
|
|
151
|
+
</div>
|
|
152
|
+
</template>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
{% endblock %}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<input
|
|
5
|
+
{% if input_type %}type="{{ input_type }}"{% else %}type="number"{% endif %}
|
|
6
|
+
class="form-control"
|
|
7
|
+
x-ref="glue_field"
|
|
8
|
+
x-model="value"
|
|
9
|
+
:id="glue_field.id"
|
|
10
|
+
>
|
|
11
|
+
{% endblock %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include 'django_spire/form/field/input_field.html' with input_type='password' %}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<div class="form-group">
|
|
5
|
+
<template x-for="choice in glue_field.choices" :key="choice[0]">
|
|
6
|
+
<div class="form-check">
|
|
7
|
+
<input
|
|
8
|
+
type="radio"
|
|
9
|
+
class="form-check-input"
|
|
10
|
+
:id="glue_field.id + '_' + choice[0]"
|
|
11
|
+
:name="glue_field.name"
|
|
12
|
+
:value="choice[0]"
|
|
13
|
+
:checked="value === choice[0]"
|
|
14
|
+
@change="this.value =choice[0]"
|
|
15
|
+
>
|
|
16
|
+
<label
|
|
17
|
+
class="form-check-label"
|
|
18
|
+
:for="glue_field.id + '_' + choice[0]"
|
|
19
|
+
x-text="choice[1]"
|
|
20
|
+
></label>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
</div>
|
|
24
|
+
{% endblock %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include 'django_spire/form/field/input_field.html' with input_type='range' %}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<input
|
|
5
|
+
type="text"
|
|
6
|
+
x-model="value"
|
|
7
|
+
x-ref="glue_field"
|
|
8
|
+
hidden
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class="position-relative"
|
|
13
|
+
x-data="{
|
|
14
|
+
placeholder: '------------',
|
|
15
|
+
show_dropdown: false,
|
|
16
|
+
search: '',
|
|
17
|
+
is_search_focused: false,
|
|
18
|
+
choice_verbose: this.placeholder,
|
|
19
|
+
|
|
20
|
+
init() {
|
|
21
|
+
this.update_choice();
|
|
22
|
+
|
|
23
|
+
$watch('value', (value) => {
|
|
24
|
+
this.update_choice();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
$watch('glue_field.choices', () => {
|
|
28
|
+
this.update_choice();
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
get filtered_choices() {
|
|
33
|
+
return glue_field.choices.filter(choice => {
|
|
34
|
+
let label = choice[1].toLowerCase();
|
|
35
|
+
let search = this.search.toLowerCase();
|
|
36
|
+
return label.includes(search);
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
focus_input() {
|
|
41
|
+
if (!is_touch_device()) {
|
|
42
|
+
this.$nextTick(() => {
|
|
43
|
+
if (this.show_dropdown) {
|
|
44
|
+
this.$refs.search_input.focus();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
handle_click(event) {
|
|
51
|
+
if (!this.$refs.search_input.contains(event.target) && !this.is_search_focused || !this.is_search_focused && this.show_dropdown) {
|
|
52
|
+
this.show_dropdown = false;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
select_choice(choice) {
|
|
57
|
+
this.value = choice[0];
|
|
58
|
+
this.search = '';
|
|
59
|
+
this.show_dropdown = false;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
update_choice() {
|
|
63
|
+
let match = this.glue_field.choices.find(choice => String(choice[0]) === String(this.value));
|
|
64
|
+
this.choice_verbose = match ? match[1] : this.placeholder;
|
|
65
|
+
}
|
|
66
|
+
}"
|
|
67
|
+
@click.outside="handle_click"
|
|
68
|
+
>
|
|
69
|
+
<button
|
|
70
|
+
class="form-control text-start d-flex justify-content-between"
|
|
71
|
+
type="button"
|
|
72
|
+
style="outline: none; box-shadow: none;"
|
|
73
|
+
@click="$event.target.blur(); focus_input(); show_dropdown = !show_dropdown;"
|
|
74
|
+
>
|
|
75
|
+
<span x-text="choice_verbose"></span>
|
|
76
|
+
|
|
77
|
+
<span class="d-flex align-items-center">
|
|
78
|
+
{% include 'django_spire/form/field/element/select_down_arrow_element.html' %}
|
|
79
|
+
</span>
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
<div
|
|
83
|
+
x-show="show_dropdown"
|
|
84
|
+
class="shadow border rounded-2 mt-2 position-absolute z-3 bg-app-glue-layer-one w-100 p-0 list-group"
|
|
85
|
+
style="max-height: 300px; overflow-y: auto; z-index: 3;"
|
|
86
|
+
@keydown.escape="show_dropdown = false"
|
|
87
|
+
>
|
|
88
|
+
<div class="glue-fs--2 fw-bold ms-2 mt-1">
|
|
89
|
+
Select <span x-text="glue_field.label"></span>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div class="m-2">
|
|
93
|
+
<input
|
|
94
|
+
x-model="search"
|
|
95
|
+
class="form-control glue-fs--2"
|
|
96
|
+
placeholder="Search..."
|
|
97
|
+
type="text"
|
|
98
|
+
x-ref="search_input"
|
|
99
|
+
@blur="setTimeout(() => is_search_focused = false, 150)"
|
|
100
|
+
@keydown.enter.prevent="select_choice(filtered_choices[0])"
|
|
101
|
+
>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<template x-for="(choice, index) in filtered_choices" :key="choice[0]">
|
|
105
|
+
<div
|
|
106
|
+
class="py-1 d-flex align-items-center list-group-item px-0"
|
|
107
|
+
tabindex="0"
|
|
108
|
+
@click="glue_field.disabled_choices.includes(choice[0]) ? '' : select_choice(choice)"
|
|
109
|
+
:class="glue_field.disabled_choices.includes(choice[0]) ? 'opacity-50 glue-user-select glue-cursor-not-allowed' : 'glue-cursor-pointer bg-app-glue-layer-one-hover'"
|
|
110
|
+
@keydown.enter.prevent="select_choice(choice)"
|
|
111
|
+
>
|
|
112
|
+
{% block choice_item %}
|
|
113
|
+
{% include 'django_spire/form/field/item/select_choice_item.html' %}
|
|
114
|
+
{% endblock %}
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
{% endblock %}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<input
|
|
5
|
+
type="text"
|
|
6
|
+
x-model="value"
|
|
7
|
+
x-ref="glue_field"
|
|
8
|
+
hidden
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class="position-relative"
|
|
13
|
+
x-data="{
|
|
14
|
+
placeholder: '------------',
|
|
15
|
+
show_dropdown: false,
|
|
16
|
+
choice_verbose: this.placeholder,
|
|
17
|
+
|
|
18
|
+
init() {
|
|
19
|
+
this.update_choice();
|
|
20
|
+
|
|
21
|
+
$watch('value', (value) => {
|
|
22
|
+
this.update_choice();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
$watch('glue_field.choices', () => {
|
|
26
|
+
this.update_choice();
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
update_choice() {
|
|
31
|
+
let match = this.glue_field.choices.find(choice => String(choice[0]) === String(this.value));
|
|
32
|
+
this.choice_verbose = match ? match[1] : this.placeholder;
|
|
33
|
+
}
|
|
34
|
+
}"
|
|
35
|
+
x-effect="update_choice();"
|
|
36
|
+
>
|
|
37
|
+
<button
|
|
38
|
+
class="form-control text-start d-flex justify-content-between {{ select_padding }}"
|
|
39
|
+
type="button"
|
|
40
|
+
@click="show_dropdown = !show_dropdown"
|
|
41
|
+
>
|
|
42
|
+
<span x-text="choice_verbose"></span>
|
|
43
|
+
|
|
44
|
+
<span class="d-flex align-items-center pt-1">
|
|
45
|
+
{% include 'django_spire/form/field/element/select_down_arrow_element.html' %}
|
|
46
|
+
</span>
|
|
47
|
+
</button>
|
|
48
|
+
<div
|
|
49
|
+
x-cloak
|
|
50
|
+
x-show="show_dropdown"
|
|
51
|
+
@click.outside="show_dropdown = false"
|
|
52
|
+
class="shadow border rounded-2 mt-2 position-absolute z-3 bg-app-glue-layer-one w-100 p-0 list-group"
|
|
53
|
+
style="max-height: 300px; overflow-y: auto; z-index: 3;"
|
|
54
|
+
@keydown.escape="show_dropdown = false"
|
|
55
|
+
x-trap.inert="show_dropdown"
|
|
56
|
+
>
|
|
57
|
+
{% block select_dropdown_header %}
|
|
58
|
+
{% endblock %}
|
|
59
|
+
|
|
60
|
+
<template x-for="(choice, index) in glue_field.choices" :key="choice[0]">
|
|
61
|
+
<div
|
|
62
|
+
class="py-1 d-flex align-items-center list-group-item px-0"
|
|
63
|
+
tabindex="0"
|
|
64
|
+
@click="glue_field.disabled_choices.includes(choice[0]) ? '' : value = choice[0]; show_dropdown = false"
|
|
65
|
+
:class="glue_field.disabled_choices.includes(choice[0]) ? 'opacity-50 glue-user-select glue-cursor-not-allowed' : 'glue-cursor-pointer bg-app-glue-layer-one-hover'"
|
|
66
|
+
@keydown.enter.prevent="value = choice[0]; show_dropdown = false"
|
|
67
|
+
>
|
|
68
|
+
{% block choice_item %}
|
|
69
|
+
{% include 'django_spire/form/field/item/select_choice_item.html' %}
|
|
70
|
+
{% endblock %}
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
{% block select_dropdown_footer %}
|
|
75
|
+
{% endblock %}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
{% endblock %}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<div
|
|
5
|
+
class="glue-form-group"
|
|
6
|
+
x-init="glue_field.hide_label()"
|
|
7
|
+
>
|
|
8
|
+
<div>
|
|
9
|
+
<div class="d-flex align-items-center">
|
|
10
|
+
<input
|
|
11
|
+
type="checkbox"
|
|
12
|
+
class="glue-form-check-input me-2"
|
|
13
|
+
:id="glue_field.id"
|
|
14
|
+
:name="glue_field.name"
|
|
15
|
+
x-model="value"
|
|
16
|
+
x-ref="glue_field"
|
|
17
|
+
style="accent-color: var(--glue-primary);"
|
|
18
|
+
>
|
|
19
|
+
<label
|
|
20
|
+
class="glue-form-check-label glue-text-primary glue-cursor-pointer"
|
|
21
|
+
:for="glue_field.id"
|
|
22
|
+
x-text="glue_field.label"
|
|
23
|
+
></label>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
{% endblock %}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/_base_file_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block x-data %}
|
|
4
|
+
async handle_files_change(event) {
|
|
5
|
+
let files = Array.from(event.target.files || []);
|
|
6
|
+
if (files.length === 0) return;
|
|
7
|
+
|
|
8
|
+
this.files = [];
|
|
9
|
+
|
|
10
|
+
Object.keys(this.objects).forEach(id => {
|
|
11
|
+
URL.revokeObjectURL(this.files.find(file => file.id === id)?.data);
|
|
12
|
+
URL.revokeObjectURL(this.files.find(file => file.id === id)?.preview);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
this.objects = {};
|
|
16
|
+
|
|
17
|
+
let file = files[0];
|
|
18
|
+
|
|
19
|
+
if (file.size > this.maximum_filesize) {
|
|
20
|
+
alert(`The file is too large (${this.format_file_size(file.size)}). Maximum size is
|
|
21
|
+
${this.format_file_size(this.maximum_filesize)}.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let file_id = Date.now() + '-' + Math.random().toString(36).substr(2, 9);
|
|
26
|
+
let processed = file;
|
|
27
|
+
|
|
28
|
+
if (file.type.startsWith('image/') && file.type !== 'image/svg+xml' && this.compression) {
|
|
29
|
+
processed = await this.compress(file);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.objects[file_id] = processed;
|
|
33
|
+
|
|
34
|
+
let data = URL.createObjectURL(processed);
|
|
35
|
+
|
|
36
|
+
this.files.push({
|
|
37
|
+
id: file_id,
|
|
38
|
+
name: processed.name,
|
|
39
|
+
size: processed.size,
|
|
40
|
+
type: processed.type,
|
|
41
|
+
data: data,
|
|
42
|
+
preview: processed.type.startsWith('image/') ? data : null
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.update_value();
|
|
46
|
+
this.show_dropdown = true;
|
|
47
|
+
this.update_form_files();
|
|
48
|
+
|
|
49
|
+
this.$refs.file_input.value = '';
|
|
50
|
+
this.$refs.camera_input.value = '';
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
remove_file(file_id) {
|
|
54
|
+
let file = this.files.find(file => file.id === file_id);
|
|
55
|
+
|
|
56
|
+
if (file) {
|
|
57
|
+
URL.revokeObjectURL(file.data);
|
|
58
|
+
if (file.preview) URL.revokeObjectURL(file.preview);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
delete this.objects[file_id];
|
|
62
|
+
|
|
63
|
+
this.files = [];
|
|
64
|
+
|
|
65
|
+
this.update_value();
|
|
66
|
+
this.update_form_files();
|
|
67
|
+
|
|
68
|
+
if (this.files.length === 0) {
|
|
69
|
+
this.show_dropdown = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
{% endblock %}
|
|
73
|
+
|
|
74
|
+
{% block upload_attributes %}{% endblock %}
|
|
75
|
+
{% block file_input_attributes %}{% endblock %}
|
|
76
|
+
{% block camera_input_attributes %}{% endblock %}
|
|
77
|
+
|
|
78
|
+
{% block selection_display %}
|
|
79
|
+
<template x-if="files.length === 0">
|
|
80
|
+
<span>No file selected</span>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<template x-if="files.length > 0">
|
|
84
|
+
<span x-text="truncate_name(files[0].name)"></span>
|
|
85
|
+
</template>
|
|
86
|
+
{% endblock %}
|
|
87
|
+
|
|
88
|
+
{% block drop_area_text %}
|
|
89
|
+
<span>Click to select or drag and drop a file here</span>
|
|
90
|
+
{% endblock %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include 'django_spire/form/field/input_field.html' with input_type='tel' %}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{% extends 'django_spire/form/field/base_field.html' %}
|
|
2
|
+
|
|
3
|
+
{% block field_content %}
|
|
4
|
+
<textarea
|
|
5
|
+
x-ref="glue_field"
|
|
6
|
+
type="text"
|
|
7
|
+
class="form-control"
|
|
8
|
+
x-model.debounce.500ms="value"
|
|
9
|
+
rows="{% if rows %}{{ rows }}{% else %}3{% endif %}"
|
|
10
|
+
></textarea>
|
|
11
|
+
{% endblock %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include 'django_spire/form/field/input_field.html' with input_type='time' %}
|
|
@@ -322,7 +322,8 @@
|
|
|
322
322
|
{% block scroll_container %}
|
|
323
323
|
<div
|
|
324
324
|
class="position-relative {% block scroll_container_class %}{% endblock %}"
|
|
325
|
-
style="height:
|
|
325
|
+
style="height:
|
|
326
|
+
{% block container_height %}{{ container_height|default:'600px' }}{% endblock %}; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;"
|
|
326
327
|
x-ref="scroll_container"
|
|
327
328
|
>
|
|
328
329
|
{% block scroll_content_wrapper %}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from django import template
|
|
2
|
+
from django.db.models import Model
|
|
3
|
+
|
|
4
|
+
register = template.Library()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@register.filter
|
|
8
|
+
def model_app_label(model_obj: Model) -> str:
|
|
9
|
+
"""
|
|
10
|
+
Return the Django app label for the given model instance.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
model_obj: A Django model instance.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
The app label defined by the model's app configuration.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
return model_obj._meta.app_label
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@register.filter
|
|
23
|
+
def model_name(model_obj: Model) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Return the Django model name for the given model instance.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
model_obj: A Django model instance.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
The model name (lowercased) as defined by Django's model metadata.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
return model_obj._meta.model_name
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from django.contrib.postgres.indexes import GinIndex
|
|
4
|
+
from django.contrib.postgres.search import SearchVectorField
|
|
3
5
|
from django.db import models
|
|
4
6
|
from django.urls import reverse
|
|
5
7
|
|
|
@@ -36,6 +38,9 @@ class Entry(
|
|
|
36
38
|
|
|
37
39
|
name = models.CharField(max_length=255)
|
|
38
40
|
|
|
41
|
+
_search_text = models.TextField(blank=True, default='')
|
|
42
|
+
_search_vector = SearchVectorField(null=True)
|
|
43
|
+
|
|
39
44
|
objects = EntryQuerySet.as_manager()
|
|
40
45
|
services = EntryService()
|
|
41
46
|
|
|
@@ -75,3 +80,16 @@ class Entry(
|
|
|
75
80
|
verbose_name = 'Entry'
|
|
76
81
|
verbose_name_plural = 'Entries'
|
|
77
82
|
db_table = 'django_spire_knowledge_entry'
|
|
83
|
+
indexes = [
|
|
84
|
+
GinIndex(fields=['_search_vector'], name='entry_search_vector_idx'),
|
|
85
|
+
GinIndex(
|
|
86
|
+
name='entry_name_trgm_idx',
|
|
87
|
+
fields=['name'],
|
|
88
|
+
opclasses=['gin_trgm_ops'],
|
|
89
|
+
),
|
|
90
|
+
GinIndex(
|
|
91
|
+
name='entry_search_text_trgm_idx',
|
|
92
|
+
fields=['_search_text'],
|
|
93
|
+
opclasses=['gin_trgm_ops'],
|
|
94
|
+
),
|
|
95
|
+
]
|
|
@@ -3,17 +3,24 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
from django.db.models import Q
|
|
6
|
+
|
|
6
7
|
from django_spire.contrib.ordering.querysets import OrderingQuerySetMixin
|
|
7
8
|
from django_spire.history.querysets import HistoryQuerySet
|
|
8
9
|
from django_spire.knowledge.entry.version.choices import EntryVersionStatusChoices
|
|
9
10
|
|
|
10
11
|
if TYPE_CHECKING:
|
|
11
|
-
from django_spire.auth.user.models import AuthUser
|
|
12
12
|
from django.db.models import QuerySet
|
|
13
|
+
|
|
14
|
+
from django_spire.auth.user.models import AuthUser
|
|
13
15
|
from django_spire.knowledge.entry.models import Entry
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
class EntryQuerySet(HistoryQuerySet, OrderingQuerySetMixin):
|
|
19
|
+
def get_by_version_block_id(self, version_block_id: int) -> Entry:
|
|
20
|
+
return self.get(
|
|
21
|
+
current_version__block__id=version_block_id
|
|
22
|
+
)
|
|
23
|
+
|
|
17
24
|
def has_current_version(self) -> QuerySet[Entry]:
|
|
18
25
|
return self.filter(current_version__isnull=False)
|
|
19
26
|
|
|
@@ -30,8 +37,3 @@ class EntryQuerySet(HistoryQuerySet, OrderingQuerySetMixin):
|
|
|
30
37
|
current_version__status=EntryVersionStatusChoices.DRAFT
|
|
31
38
|
)
|
|
32
39
|
)
|
|
33
|
-
|
|
34
|
-
def get_by_version_block_id(self, version_block_id: int) -> Entry:
|
|
35
|
-
return self.get(
|
|
36
|
-
current_version__block__id=version_block_id
|
|
37
|
-
)
|