Модуль:Отображение назначений
Перейти к навигации
Перейти к поиску
Для документации этого модуля может быть создана страница Модуль:Отображение назначений/doc
local pp = {}
local tools = require( 'Module:Tools' )
local perstools = require( 'Module:PersTools' )
local refTools = require( 'Module:RefTools' )
local marker = {
icon = 'sitemap',
[3] = 'Упоминание или должности подразделения в документах',
[4] = 'Предыдущее подразделение/должность при назначении',
[5] = 'Подразделение/должность при отстранении от должности',
[6] = 'Подразделение/должность на момент увольнения',
[8] = 'Назначение — ОТМЕНЕНО',
[9] = 'Отстранение от должности — ОТМЕНЕНО',
[10] = 'Увольнение — ОТМЕНЕНО',
[11] = 'Отмена решения',
[12] = 'Новая должность',
[13] = 'Отстранен от должности',
[14] = 'Исключен из списков',
}
function pp.display( query, queryCount, showP )
if queryCount == 0 then
return '<p class="nkvd-no-designation">Отсутствуют сведения о назначениях.</p>'
end
table.sort( query, function ( a, b )
return ( a.cDate or '' ) < ( b.cDate or '' )
or ( a.cDate or '' ) == ( b.cDate or '' )
and tonumber( a.origin ) < tonumber( b.origin )
end
)
local cPosition, cUnit, cSegment, cRow, cLast, cFirst, cMiddle -- , cDisambig
for i, row in ipairs( query ) do
if row['#eq'] or ( showP and row['#ap'] ) then
if row.position == cPosition
and row.unit == cUnit
and ( row.segment == cSegment or row.segment == '' )
and ( row.reference or '' ) == ''
and ( not showP or (row.nLast == cLast and row.nFirst == cFirst and row.nMiddle == cMiddle ) ) then
query[cRow].controlled = query[cRow].controlled or {}
table.insert( query[cRow].controlled, i )
row.collapsed = true
else
cPosition, cUnit, cSegment, cLast, cFirst, cMiddle, cRow
= row.position, row.unit, row.segment, row.nLast, row.nFirst, row.nMiddle, i
end
end
end
local out
if showP then
out = '<th> </th>'
else
out = ''
end
out = { [==[
<table class="nkvd-designation-table">
<tr class="nkvd-table-th">]==] .. out .. [==[
<th> </th>
<th> </th>
<th class="nkvd-table-date">дата</th>
<th style="width:2em;"> </th><!-- collapse marker -->
<th class="nkvd-table-position">должность</th>
<th class="nkvd-table-unit">подразделение/место службы</th>
<th class="nkvd-table-source">источник</th>
</tr>
]==] }
cPosition = false
local ourTitle = mw.title.getCurrentTitle().text
for i, row in ipairs( query ) do
if row['#eq'] or ( showP and row['#ap'] ) then
local classes = ''
if row.collapsed then
classes = ' mw-collapsible mw-collapsed'
cPosition = true
end
table.insert( out,
'<tr id="mw-customcollapsible-designation-' .. i .. '" class="nkvd-table-row-' .. row.origin .. classes .. '">' )
if showP then
table.insert( out, '<td class="nkvd-table-person">' .. perstools.makePersonLink( row ) .. '</td>' )
end
table.insert( out,
perstools.fixedColumns( row.origin, marker, row.cDate, row.cDate__precision ) )
if row.controlled then
table.insert( out, '<td><i class="fa fa-sign-out fa-rotate-90 fa-lg mw-customtoggle-designation-' .. table.concat( row.controlled, ' mw-customtoggle-designation-' )
.. '" title="Имеется несколько последовательных записей о той же должности" style="color:#0645AD; cursor:pointer"></i></td>' )
else
table.insert( out, '<td></td>' )
end
if row.origin == '10' or row.origin == '14' then
local dismissDb = mw.loadData 'Модуль:Виды увольнения'
local t = dismissDb.dirParam[tonumber(row.dismissal_type)]
table.insert( out,
'<td class="nkvd-table-position">' .. t.pre .. ' '
.. t.txt .. ' ' .. (dismissDb.article[row.article].short or '') )
if row.formula ~= '' then
table.insert( out, ' (' .. row.formula .. ')' )
end
table.insert( out, '</td>' )
else
table.insert( out,
'<td class="nkvd-table-position">' .. row.position .. '</td>' )
end
table.insert( out,
'<td class="nkvd-table-unit">' )
local tmp = row.segment
if tmp ~= '' then
tmp = tools.segment( tmp )
if row.unit ~= '' then
tmp = row.unit .. ', ' .. tmp
end
else
tmp = row.unit
end
table.insert( out, tmp .. '</td>' )
local doc, persdoc = row._pageName, (row.alias or '')
if doc == ourTitle then
if persdoc == '' then
persdoc = 'см. дополнительные материалы'
end
else
if persdoc == '' then
persdoc = mw.title.new( doc ).text
end
persdoc = '[[' .. doc .. '|' .. persdoc .. ']]'
end
table.insert( out, '<td class="nkvd-table-source">' .. persdoc )
table.insert( out, refTools.makeRef( row.reference ) )
table.insert( out, '</td>' )
table.insert( out, '</tr>\n' )
end
end
table.insert( out, '</table>\n' )
if cPosition then
-- table.insert( out, '<p style="font-size:87%">Последовательные повторные упоминания одной и той же должности были свернуты.</p>' )
end
return table.concat( out )
end
return pp