Nastya 11 месяцев назад
Родитель
Сommit
bb00ecb941

+ 68 - 21
SharixAdmin/static/drf-yasg/service_type.css

@@ -1,3 +1,5 @@
+
+
 h1.mainHeader {
     font-weight: 700;
     font-size: 28px;
@@ -12,30 +14,75 @@ p.description_service {
     margin-top: 14px;
 }
 
-/* #overlay {
-    position: fixed;
-    top: 0;
-    left: 0;
-    right: 0;
-    bottom: 0;
-    background-color: rgba(0, 0, 0, 0.5);
-    display: none;
-  }
-  
-  
-  #overlay.show {
-    display: block;
-    width: 400px;
-    height: 700px;
-    background-color: white;
-  } */
-
-
-th {
-    color: rgb(0, 0, 0);
+
+/* table th {
     font-size: 14px;
     line-height: 24px;
     font-weight: 700;
+    border: 1px solid #ffffff;
+    text-decoration: none;
+} */
+
+table.table thead th.orderable {
+    background: url('service_type/arrow_fil.svg') no-repeat center right;
+}
+table.table thead th.asc {
+    background: url('service_type/arrow_asc.svg') no-repeat center right;
+}
+table.table thead th.desc {
+    background: url('service_type/arrow_desc.svg') no-repeat center right;
+}
+
+.delete_col {
+    background: url('service_type/delete.svg') no-repeat center right;
+}
+.delete_col a {
+    color: transparent;
+    line-height: 24px;
+}
+.delete_col a:hover {
+    color: transparent;
+}
+
+.edit_col a {
+    color: transparent;
+}
+.edit_col a:hover {
+    color: transparent;
+}
+.edit_col{
+    background: url('service_type/pencil.svg') no-repeat center right;
+}
+
+
+.description_col {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    max-width: 610px;
+    justify-content: center;
+    &:hover {
+        white-space: normal;
 }
+}
+
 
+table.table thead th {
+    border: 1px #ffffff;
+}
+.description_col-active {
+    border: 1px #95C0F6;
+}
+.test {
+    width: 50px;
+    height: 50px;
+    margin-left: 30px;
+    background-color: #95C0F6;
+}
 
+table.table {
+    border-collapse: collapse;
+}
+table tr {
+    
+}

+ 0 - 0
SharixAdmin/static/SharixAdmin/service_type/arrow_fil.svg → SharixAdmin/static/drf-yasg/service_type/arrow_asc.svg


+ 3 - 0
SharixAdmin/static/drf-yasg/service_type/arrow_desc.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
+  <path d="M17.71 11.29L12.71 6.29002C12.6149 6.19898 12.5028 6.12761 12.38 6.08002C12.1365 5.98 11.8635 5.98 11.62 6.08002C11.4973 6.12761 11.3851 6.19898 11.29 6.29002L6.29 11.29C6.19676 11.3833 6.1228 11.4939 6.07234 11.6158C6.02188 11.7376 5.99591 11.8682 5.99591 12C5.99591 12.2663 6.1017 12.5217 6.29 12.71C6.47831 12.8983 6.7337 13.0041 7 13.0041C7.2663 13.0041 7.5217 12.8983 7.71 12.71L11 9.41002L11 17C11 17.2652 11.1054 17.5196 11.2929 17.7071C11.4804 17.8947 11.7348 18 12 18C12.2652 18 12.5196 17.8947 12.7071 17.7071C12.8946 17.5196 13 17.2652 13 17L13 9.41002L16.29 12.71C16.383 12.8037 16.4936 12.8781 16.6154 12.9289C16.7373 12.9797 16.868 13.0058 17 13.0058C17.132 13.0058 17.2627 12.9797 17.3846 12.9289C17.5064 12.8781 17.617 12.8037 17.71 12.71C17.8037 12.6171 17.8781 12.5065 17.9289 12.3846C17.9797 12.2627 18.0058 12.132 18.0058 12C18.0058 11.868 17.9797 11.7373 17.9289 11.6154C17.8781 11.4936 17.8037 11.383 17.71 11.29Z" fill="#202020"/>
+</svg>

+ 3 - 0
SharixAdmin/static/drf-yasg/service_type/arrow_fil.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
+  <path d="M6.29 12.7101L11.29 17.7101C11.3851 17.8011 11.4972 17.8725 11.62 17.9201C11.8635 18.0201 12.1365 18.0201 12.38 17.9201C12.5027 17.8725 12.6149 17.8011 12.71 17.7101L17.71 12.7101C17.8032 12.6169 17.8772 12.5062 17.9277 12.3844C17.9781 12.2625 18.0041 12.132 18.0041 12.0001C18.0041 11.7338 17.8983 11.4784 17.71 11.2901C17.5217 11.1018 17.2663 10.996 17 10.996C16.7337 10.996 16.4783 11.1018 16.29 11.2901L13 14.5901L13 7.0001C13 6.73489 12.8946 6.48053 12.7071 6.293C12.5196 6.10546 12.2652 6.0001 12 6.0001C11.7348 6.0001 11.4804 6.10546 11.2929 6.293C11.1054 6.48053 11 6.73489 11 7.0001L11 14.5901L7.71 11.2901C7.61703 11.1964 7.50644 11.122 7.38458 11.0712C7.26272 11.0204 7.13201 10.9943 7 10.9943C6.86799 10.9943 6.73728 11.0204 6.61542 11.0712C6.49356 11.122 6.38296 11.1964 6.29 11.2901C6.19627 11.3831 6.12188 11.4937 6.07111 11.6155C6.02034 11.7374 5.9942 11.8681 5.9942 12.0001C5.9942 12.1321 6.02034 12.2628 6.07111 12.3847C6.12188 12.5065 6.19627 12.6171 6.29 12.7101Z" fill="#202020"/>
+</svg>

+ 3 - 0
SharixAdmin/static/drf-yasg/service_type/delete.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="25" height="24" viewBox="0 0 25 24" fill="none">
+  <path d="M10.5 18C10.7652 18 11.0196 17.8946 11.2071 17.7071C11.3946 17.5196 11.5 17.2652 11.5 17V11C11.5 10.7348 11.3946 10.4804 11.2071 10.2929C11.0196 10.1054 10.7652 10 10.5 10C10.2348 10 9.98043 10.1054 9.79289 10.2929C9.60536 10.4804 9.5 10.7348 9.5 11V17C9.5 17.2652 9.60536 17.5196 9.79289 17.7071C9.98043 17.8946 10.2348 18 10.5 18ZM20.5 6H16.5V5C16.5 4.20435 16.1839 3.44129 15.6213 2.87868C15.0587 2.31607 14.2956 2 13.5 2H11.5C10.7044 2 9.94129 2.31607 9.37868 2.87868C8.81607 3.44129 8.5 4.20435 8.5 5V6H4.5C4.23478 6 3.98043 6.10536 3.79289 6.29289C3.60536 6.48043 3.5 6.73478 3.5 7C3.5 7.26522 3.60536 7.51957 3.79289 7.70711C3.98043 7.89464 4.23478 8 4.5 8H5.5V19C5.5 19.7956 5.81607 20.5587 6.37868 21.1213C6.94129 21.6839 7.70435 22 8.5 22H16.5C17.2956 22 18.0587 21.6839 18.6213 21.1213C19.1839 20.5587 19.5 19.7956 19.5 19V8H20.5C20.7652 8 21.0196 7.89464 21.2071 7.70711C21.3946 7.51957 21.5 7.26522 21.5 7C21.5 6.73478 21.3946 6.48043 21.2071 6.29289C21.0196 6.10536 20.7652 6 20.5 6ZM10.5 5C10.5 4.73478 10.6054 4.48043 10.7929 4.29289C10.9804 4.10536 11.2348 4 11.5 4H13.5C13.7652 4 14.0196 4.10536 14.2071 4.29289C14.3946 4.48043 14.5 4.73478 14.5 5V6H10.5V5ZM17.5 19C17.5 19.2652 17.3946 19.5196 17.2071 19.7071C17.0196 19.8946 16.7652 20 16.5 20H8.5C8.23478 20 7.98043 19.8946 7.79289 19.7071C7.60536 19.5196 7.5 19.2652 7.5 19V8H17.5V19ZM14.5 18C14.7652 18 15.0196 17.8946 15.2071 17.7071C15.3946 17.5196 15.5 17.2652 15.5 17V11C15.5 10.7348 15.3946 10.4804 15.2071 10.2929C15.0196 10.1054 14.7652 10 14.5 10C14.2348 10 13.9804 10.1054 13.7929 10.2929C13.6054 10.4804 13.5 10.7348 13.5 11V17C13.5 17.2652 13.6054 17.5196 13.7929 17.7071C13.9804 17.8946 14.2348 18 14.5 18Z" fill="#EF3232"/>
+</svg>

+ 3 - 0
SharixAdmin/static/drf-yasg/service_type/pencil.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="25" height="24" viewBox="0 0 25 24" fill="none">
+  <path d="M22.5 7.24002C22.5008 7.10841 22.4756 6.97795 22.4258 6.85611C22.376 6.73427 22.3027 6.62346 22.21 6.53002L17.97 2.29002C17.8766 2.19734 17.7658 2.12401 17.6439 2.07425C17.5221 2.02448 17.3916 1.99926 17.26 2.00002C17.1284 1.99926 16.9979 2.02448 16.8761 2.07425C16.7543 2.12401 16.6435 2.19734 16.55 2.29002L13.72 5.12002L2.79002 16.05C2.69734 16.1435 2.62401 16.2543 2.57425 16.3761C2.52448 16.4979 2.49926 16.6284 2.50002 16.76V21C2.50002 21.2652 2.60537 21.5196 2.79291 21.7071C2.98045 21.8947 3.2348 22 3.50002 22H7.74002C7.87994 22.0076 8.01991 21.9857 8.15084 21.9358C8.28176 21.8858 8.40073 21.8089 8.50002 21.71L19.37 10.78L22.21 8.00002C22.3013 7.9031 22.3757 7.79155 22.43 7.67002C22.4397 7.59031 22.4397 7.50973 22.43 7.43002C22.4347 7.38347 22.4347 7.33657 22.43 7.29002L22.5 7.24002ZM7.33002 20H4.50002V17.17L14.43 7.24002L17.26 10.07L7.33002 20ZM18.67 8.66002L15.84 5.83002L17.26 4.42002L20.08 7.24002L18.67 8.66002Z" fill="#479FF8"/>
+</svg>

+ 11 - 8
SharixAdmin/tables.py

@@ -116,11 +116,14 @@ class ServiceTypeTable(tables.Table):
 
     id = tables.Column( attrs={"td":{"width":"5%"}})
     codename = tables.LinkColumn('service_type/edit/', verbose_name='Услуга', orderable=False, text = lambda record: record.codename,
-        args=[tables.A('pk')], attrs={'th':{'scope':'col'},})
+        args=[tables.A('pk')], attrs= {"a": {"style": "pointer-events: none;"}, 'th':{'scope':'col'}, "td":{"class":"name_col"}})
     description = tables.LinkColumn('service_type/edit/', orderable=False, verbose_name='Описание', text = lambda record: record.description,
-        args=[tables.A('pk')], attrs={'th':{'scope':'col'}, })
-    deletee = tables.LinkColumn('service_type/delete/', verbose_name='', text = "Удалить",
-        args=[tables.A('pk')], attrs={'th':{'scope':'col'},})
+        args=[tables.A('pk')], attrs= {"a": {"style": "pointer-events: none;"}, 'th':{'scope':'col'}, "td":{"class":"description_col"}})
+    edit = tables.LinkColumn('service_type/edit/', verbose_name='', orderable=False, text = "E",
+        args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"class":"edit_col"}})
+    deletee = tables.LinkColumn('service_type/delete/', verbose_name='', orderable=False, text = "D",
+        args=[tables.A('pk')], attrs={'th':{'scope':'col'}, "td":{"class":"delete_col"}})
+    
     
     class Meta:
         model = ServiceType
@@ -130,11 +133,11 @@ class ServiceTypeTable(tables.Table):
                    'id_metaservice', 'link_agreement',
                    'is_global', 'is_visible', 'caption')
 
-    def render_delete(self, value, record):
-        return format_html('<a href="/service_type/delete" class="btn btn-outline-danger">_(Delete)</a>')
+    # def render_delete(self, value, record):
+    #     return format_html('<a href="/service_type/delete" class="btn btn-outline-danger">_(Delete)</a>')
         
-    def render_name_operation(self, value, record):
-        return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
+    # def render_name_operation(self, value, record):
+    #     return format_html("<a href='{}'>{}</a>", record.get_absolute_url(), value)
    
 class ServiceTable(tables.Table):
 

+ 22 - 5
SharixAdmin/templates/SharixAdmin/service_type.html

@@ -21,11 +21,11 @@
       <p class="description_service">Это система управления государством, источником власти в которой является сам народ. Именно народ решает, какие законы и нормы необходимы для гармоничного существования и развития государства. Таким образом, каждый человек в демократическом обществе 
         Получает определенный набор свобод и обязательств сформированных с учетом интересов всего сообщества. Исходя из вышесказанного, можно заключить, что демократия – это возможность для каждого человека свободно участвовать в непосредственном управлении своим государством, обществом и личной судьбой в конечном счете.</p>
       <div class="row justify-content-start">
-        {% render_table table %}
-        <div class="filter_id" style="">
-          <img src="{% static 'SharixAdmin/service_type/arrow_fil.svg' %}"
-          style="width: 20px; height: 20px;">
+        <div class="smalldesc" id="maintable">
+          {% render_table table %}
         </div>
+        
+
 
         <!-- {% comment %} {% if table.page %}
           <nav aria-label="...">
@@ -64,11 +64,28 @@
           </nav>
         {% endif %} {% endcomment %} -->
   </div>
+
   <div class="container text-end mt-2">
-    <a class="btn btn-primary" href="/service_type/add">{% trans 'Add' %}</a>
+    <a class="btn btn-primary" id="bord" href="/service_type/add">{% trans 'Add' %}</a>
   </div>
       </div>
 
+<script>
+  // var colors = document.getElementById("test1"); 
+  // var changeBorder =  
+  //     document.getElementById("test1"); 
+  // changeBorder.addEventListener("click", function () { 
+  //   test1.style.border = "3px solid green"; 
+  //   test1.style.borderRadius = "10px"; 
+  // }); 
+
+  var rows = document.getElementsByTagName("tr");
+  changeBorder.addEventListener("click", function () { 
+    row.style.border = "3px solid green"; 
+    row.style.borderRadius = "10px"; 
+  }); 
+</script>
+
 
 
 {% endblock contenthome %}

+ 5 - 0
SharixAdmin/templates/SharixAdmin/service_type_form.html

@@ -20,3 +20,8 @@
     </div>
 </form>
 {% endblock %}
+
+<script>
+document.querySelector(".description_col").addEventListener("click", ({ target }) =>
+target.closest('.description_col')?.classList.toggle('description_col-active'));
+</script>

+ 9 - 4
SharixAdmin/views/service_type.py

@@ -56,23 +56,27 @@ class ServiceTypeListView(UserPassesTestMixin, SingleTableView):
 
 class ServiceTypeUpdateView(UserPassesTestMixin, UpdateView):
     model = ServiceType
-    form_class = ServiceTypeUpdateForm
+    form_class = ServiceTypeCreateForm
     template_name = "SharixAdmin/service_type_form.html"
 
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context.update(get_context(self.request, {
-            'title': 'Услуги сервиса',
-            'object_list': context['object_list'],
+            'title': _('Услуги сервиса'),
+            'object': self.object,
         }))
         return context
     
+    
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
         if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     
+    def get_success_url(self):
+        return reverse('service_type')
+    
 
 class ServiceTypeDelete(UserPassesTestMixin, DeleteView):
     model = ServiceType
@@ -93,4 +97,5 @@ class ServiceTypeDelete(UserPassesTestMixin, DeleteView):
         group_names = ('METASERVICE-ADMIN')
         if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
-        return False
+        return False
+