Обучаю битриксу программистов, интеграторов. Подробнee ⇒

Кастомизация вида элемента списка в режиме чтения



Элемент списка в Битрикс24  в режиме чтения почти такой же, как и в режиме редактирования. только нет возможности "сохранить".
А поля все радактируемые.
Поправила БЕЗ кастомизаций шаблона.
ид списка 222

файл с вызовом компонента /services/lists/index.php
в нем подключила jquery
\CJSCore::init(array("jquery"));
и js добавила проверку, что список 222 и нет кнопки "сохранить" (что значит режим на чтение)
if($('#form_lists_element_edit_222').length>0 && $('#form_lists_element_edit_222 input[name=apply]').length == 0){
если режим на чтение, то добавляются файл со скриптом  list_view.js и файл со стилем list_view.css
<?php
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/header.php');
\CJSCore::init(array("jquery"));
IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/intranet/public/services/lists/index.php');
$APPLICATION->SetTitle(GetMessage('SERVICES_TITLE'));
$APPLICATION->IncludeComponent(
   'bitrix:lists',
   '.default',
   [
      'IBLOCK_TYPE_ID' => 'lists',
      'SEF_MODE' => 'Y',
      'SEF_FOLDER' => SITE_DIR.'services/lists/',
      'CACHE_TYPE' => 'A',
      'CACHE_TIME' => '36000000',
      'SEF_URL_TEMPLATES' => [
         'lists' => '',
         'list' => '#list_id#/view/#section_id#/',
         'list_sections' => '#list_id#/edit/#section_id#/',
         'list_edit' => '#list_id#/edit/',
         'list_fields' => '#list_id#/fields/',
         'list_field_edit' => '#list_id#/field/#field_id#/',
      ]
   ],
   false
);?>
<script>
$(document).ready(function() {

   if($('#form_lists_element_edit_222').length>0 && $('#form_lists_element_edit_222 input[name=apply]').length == 0){
      var myScript = document.createElement('script');
      myScript.src = 'https://bitrix.nikaverro.ru/services/lists/list_view.js?1';
      document.head.appendChild(myScript);

      var link  = document.createElement('link');    
       link.rel  = 'stylesheet';
       link.type = 'text/css';
       link.href = 'https://bitrix.nikaverro.ru/services/lists/list_view.css?1';
       link.media = 'all';
       document.head.appendChild(link);
   }
});
</script>
<?require($_SERVER['DOCUMENT_ROOT'].'/bitrix/footer.php');
файл list_view.js
$(document).ready(function(){
   $('#form_lists_element_edit_222').css('opacity',0);
   $('#tab_el_edit_table input[type=text]').prop( "disabled", true );
   $('#tab_el_edit_table select').prop( "disabled", true );
   $('#tab_el_edit_table select').prop( "disabled", true );
   let onclick = $('#form_lists_element_edit_222 input[name=cancel]').attr('onclick'); 
   $('#form_lists_element_edit_222 .bx-buttons').append('<a href="#" onlick="'+onclick+'">К списку сотрудников</a>'); //меняю кнопку "отмена"
   $('#pagetitle').html("Сотрудник: "+$('#tab_el_edit_table>tbody>tr:nth-child(2) a').first().html()); //заголовок меняю
   setTimeout(function(){
       $('.bxhtmled-iframe-cnt').each(function(ind,el){ //убираем BXHtmlEditor
     let editorId = el.id.replace("bx-html-editor-iframe-cnt-","");
          $(el).parents('.bx-field-value').first().html(window.BXHtmlEditor.editors[editorId].content);
      });
      $('#form_lists_element_edit_222').css('opacity',1);
   },100);

});
файл list_view.css
#tab_tab_bp,
#tab_bp_edit_table,
#tab_el_edit_table .calendar-icon,
#tab_el_edit_table .ui-ctl-icon-calendar,
#tab_el_edit_table .bxhtmled-toolbar-cnt,
#tab_el_edit_table input[type=file],
#form_lists_element_edit_222 input[type=button],
#form_lists_element_edit_222 input[type=checkbox],
#form_lists_element_edit_222 label,
.bx-form-notes{
   display: none;
}
#tab_el_edit_table>tbody>tr:nth-child(2){
   display: table-row!important;
}
#tab_el_edit_table input[type=text]:disabled,
#tab_el_edit_table select:disabled{
   opacity: 1;
   border-color: transparent; 
}

#form_lists_element_edit_222 .bx-buttons a{
    display: inline-block;
    margin-top: 40px;
    margin-bottom: 30px;
    height: 32px;
    border-top: 1px solid #c8d1d4;
    border-bottom: 1px solid #98a4a9;
    border-left: 1px solid #a9b4b8;
    border-right: 1px solid #a9b4b8;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    -khtml-border-radius: 4px;
    border-radius: 4px;
    padding: 0 45px;
    margin-right: 10px;
    -webkit-box-shadow: 0 2px 2px #ccc;
    -moz-box-shadow: 0 2px 2px #ccc;
    box-shadow: 0 2px 2px #ccc;
    font: var(--ui-font-weight-bold) 14px/32px var(--ui-font-family-primary, var(--ui-font-family-helvetica));
    color: #555;
    text-shadow: #fff 0 1px 1px !important;
    cursor: pointer;
    outline: 0;
    overflow: visible;
    background: url(/bitrix/templates/bitrix24/images/interface/buttons-sprite.png) repeat-x left -585px;
}
#form_lists_element_edit_222 .bx-buttons a:hover{
   background-position: left -624px;
}
Если блог был полезным, можете угостить меня "чашечкой кофе" :)

Сбер по номеру телефона +7 (953) 585-13-09 Вероника.
Спасибо!