-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #985 from solita/feature/AE-1980
AE-1980: Allow toggling document for osapuoli in Sakkopäätös / kuulemiskirje toimenpidetype
- Loading branch information
Showing
5 changed files
with
208 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
src/pages/valvonta-kaytto/osapuolet-table-with-document-selection.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<script> | ||
import * as R from 'ramda'; | ||
import * as Maybe from '@Utility/maybe-utils'; | ||
import * as Locales from '@Language/locale-utils'; | ||
import * as Osapuolet from './osapuolet'; | ||
import * as Templates from './templates'; | ||
import * as ValvontaApi from './valvonta-api'; | ||
import { _, locale } from '@Language/i18n'; | ||
import H2 from '@Component/H/H2.svelte'; | ||
import Spinner from '@Component/Spinner/Spinner.svelte'; | ||
import * as Toimenpiteet from '@Pages/valvonta-kaytto/toimenpiteet'; | ||
import Checkbox from '@Component/Checkbox/Checkbox'; | ||
export let id; | ||
export let toimenpide; | ||
export let henkilot; | ||
export let yritykset; | ||
export let preview; | ||
export let roolit; | ||
export let template; | ||
export let previewPending; | ||
export let disabled; | ||
const types = { | ||
yritys: { | ||
label: yritys => yritys.nimi, | ||
preview: ValvontaApi.previewToimenpideForYritysOsapuoli | ||
}, | ||
henkilo: { | ||
label: henkilo => `${henkilo.etunimi} ${henkilo.sukunimi}`, | ||
preview: ValvontaApi.previewToimenpideForHenkiloOsapuoli | ||
} | ||
}; | ||
let osapuolet = R.sort(R.ascend(R.prop('toimitustapa-id')))( | ||
R.concat( | ||
R.map(R.assoc('type', types.henkilo), henkilot), | ||
R.map(R.assoc('type', types.yritys), yritykset) | ||
) | ||
); | ||
const i18n = $_; | ||
const i18nRoot = 'valvonta.kaytto.toimenpide'; | ||
$: rooliLabel = R.compose( | ||
Maybe.fold('', Locales.labelForId($locale, roolit)), | ||
R.prop('rooli-id') | ||
); | ||
const osapuoliSpecificDataIndexForOsapuoli = osapuoli => | ||
Toimenpiteet.osapuoliSpecificDataIndexForOsapuoli( | ||
toimenpide, | ||
osapuoli.id, | ||
Osapuolet.getOsapuoliType(osapuoli) | ||
); | ||
</script> | ||
|
||
<div class="w-full"> | ||
<H2 text={i18n(i18nRoot + '.vastaanottajat')} /> | ||
|
||
<div class="flex flex-row my-4"> | ||
<table class="etp-table"> | ||
<thead class="etp-table--thead"> | ||
<tr class="etp-table--tr etp-table--tr__light"> | ||
<th class="etp-table--th"> {i18n(i18nRoot + '.nimi')} </th> | ||
|
||
<th class="etp-table--th"> {i18n(i18nRoot + '.rooli')} </th> | ||
|
||
<th class="etp-table--th"> | ||
{i18n(i18nRoot + '.toimitustapa')} | ||
</th> | ||
|
||
<th class="etp-table--th"> | ||
{i18n(i18nRoot + '.esikatselu')} | ||
</th> | ||
<th class="etp-table--th">{i18n(i18nRoot + '.create-document')}</th> | ||
</tr> | ||
</thead> | ||
<tbody class="etp-table--tbody"> | ||
{#each osapuolet as osapuoli} | ||
<tr class="etp-table-tr"> | ||
<td class="etp-table--td"> | ||
{osapuoli.type.label(osapuoli)} | ||
</td> | ||
<td class="etp-table--td"> | ||
{rooliLabel(osapuoli)} | ||
{#if Osapuolet.otherRooli(osapuoli)} | ||
- {Maybe.orSome('', osapuoli['rooli-description'])} | ||
{/if} | ||
</td> | ||
<td class="etp-table--td"> | ||
{i18n('valvonta.kaytto.toimenpide.manually-sent')} | ||
</td> | ||
<td class="etp-table--td"> | ||
{#if Osapuolet.isOmistaja(osapuoli)} | ||
{#if previewPending} | ||
<div class="etp-table--td__center"> | ||
<Spinner smaller={true} /> | ||
</div> | ||
{:else} | ||
<div | ||
class:text-primary={!disabled} | ||
class:text-disabled={disabled} | ||
class:invisible={!Toimenpiteet.documentExistsForOsapuoli( | ||
toimenpide, | ||
osapuoli.id, | ||
Osapuolet.getOsapuoliType(osapuoli) | ||
)} | ||
class="cursor-pointer etp-table--td__center" | ||
role="button" | ||
on:click|stopPropagation={disabled || | ||
preview( | ||
osapuoli.type.preview(id, osapuoli.id, toimenpide) | ||
)}> | ||
<span class="font-icon text-2xl"> visibility </span> | ||
</div> | ||
{/if} | ||
{:else if Maybe.orSome(false, R.lift(Templates.sendTiedoksi)(template))} | ||
<span class="font-icon">info</span> | ||
{i18n(i18nRoot + '.fyi')} | ||
{:else} | ||
<span class="font-icon">info</span> | ||
{i18n(i18nRoot + '.fyi-disabled')} | ||
{/if} | ||
</td> | ||
<td class="etp-table--td"> | ||
<div class="etp-table--td__center"> | ||
{#if Osapuolet.isOmistaja(osapuoli)} | ||
<Checkbox | ||
bind:model={toimenpide} | ||
lens={R.lensPath([ | ||
'type-specific-data', | ||
'osapuoli-specific-data', | ||
osapuoliSpecificDataIndexForOsapuoli(osapuoli), | ||
'document' | ||
])} /> | ||
{/if} | ||
</div> | ||
</td> | ||
</tr> | ||
{/each} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters