Skip to content

Commit

Permalink
Merge pull request #33 from velrest/link-buildings
Browse files Browse the repository at this point in the history
Link buildings
  • Loading branch information
czosel authored Mar 22, 2021
2 parents 64fc76a + c8c78c2 commit 74fa404
Show file tree
Hide file tree
Showing 56 changed files with 1,498 additions and 314 deletions.
44 changes: 44 additions & 0 deletions addon/components/link-building-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<UkModal @visible={{@visible}} @on-hide={{@close}} as |Modal|>
<Modal.header>
<h2 class="uk-modal-title">
{{t "ember-gwr.components.linkBuildingModal.linkBuilding"}}
</h2>
</Modal.header>
<Modal.body>
{{#let
(component
"project-form/field"
project=this.buildingWork
translationBase="ember-gwr.buildingWork"
) as |Field|
}}
<Field
@attr="constructionWorkDone"
@inputType="select"
@noPlaceholder={{true}}
@options={{this.kindOfWorkOptions}}
/>
<Field @attr="energeticRestauration" @inputType="checkbox" />
<Field @attr="renovationHeatingsystem" @inputType="checkbox" />
<Field @attr="innerConversionRenovation" @inputType="checkbox" />
<Field @attr="conversion" @inputType="checkbox" />
<Field @attr="extensionHeighteningHeated" @inputType="checkbox" />
<Field @attr="extensionHeighteningNotHeated" @inputType="checkbox" />
<Field @attr="thermicSolarFacility" @inputType="checkbox" />
<Field @attr="photovoltaicSolarFacility" @inputType="checkbox" />
<Field @attr="otherWorks" @inputType="checkbox" />
{{/let}}
</Modal.body>
<Modal.footer class="uk-flex uk-flex-between">
<UkButton {{on "click" @close}}>
{{t "ember-gwr.components.linkBuildingModal.cancel"}}
</UkButton>
<UkButton
@color="primary"
@loading={{@isLoading}}
{{on "click" (fn @linkAction this.buildingWork)}}
>
{{t "ember-gwr.components.linkBuildingModal.linkBuilding"}}
</UkButton>
</Modal.footer>
</UkModal>
19 changes: 19 additions & 0 deletions addon/components/link-building-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { kindOfWorkOptions } from "ember-ebau-gwr/models/options";

export default class LinkBuildingModalComponent extends Component {
@tracked buildingWork = {
constructionWorkDone: kindOfWorkOptions[0],
energeticRestauration: false,
renovationHeatingsystem: false,
innerConversionRenovation: false,
conversion: false,
extensionHeighteningHeated: false,
extensionHeighteningNotHeated: false,
thermicSolarFacility: false,
photovoltaicSolarFacility: false,
otherWorks: false,
};
kindOfWorkOptions = kindOfWorkOptions;
}
82 changes: 82 additions & 0 deletions addon/components/linked-models.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{#let (t (concat "ember-gwr.models." @modelName)) as |modelName|}}
<table class="uk-table uk-table-divider uk-table-hover uk-table-middle">
<thead>
<tr>
<th colspan="3">
{{t
"ember-gwr.components.linkedModels.linkedEntries"
modelName=modelName
}}
</th>
</tr>
</thead>
<tbody>
{{#each @models as |model|}}
<tr>
{{#if hasBlock}}
{{yield model}}
{{else}}
<td class="uk-table-shrink">
<LinkTo
@route={{concat @modelName ".form"}}
@model={{get model @idAttr}}
class="uk-link"
>
{{get model @idAttr}}
</LinkTo>
</td>
<td>
{{get model @descriptionAttr}}
</td>
{{/if}}
{{#unless @noDeleteButton}}
<td class="uk-table-shrink">
<button
type="button"
class="uk-icon-button"
uk-icon="trash"
uk-tooltip={{t "ember-gwr.components.linkedModels.removeLink"}}
{{on "click" (fn @removeLink model)}}
>
</button>
</td>
{{/unless}}
</tr>
{{else}}
<tr>
<td colspan="3">
{{t
"ember-gwr.components.linkedModels.noLinkedEntries"
modelName=modelName
}}
</td>
</tr>
{{/each}}
</tbody>
<tfoot>
<tr>
<td colspan="99" class="uk-text-center">
<LinkTo
@route={{or @searchRoute (concat "search-" @modelName)}}
@models={{or @searchModels (array)}}
>
{{t
"ember-gwr.components.linkedModels.linkEntry"
modelName=modelName
}}
</LinkTo>
{{t "ember-gwr.components.linkedModels.or"}}
<LinkTo
@route={{or @newRoute (concat @modelName ".new")}}
@models={{or @newModels (array)}}
>
{{t
"ember-gwr.components.linkedModels.createEntry"
modelName=modelName
}}
</LinkTo>
</td>
</tr>
</tfoot>
</table>
{{/let}}
60 changes: 0 additions & 60 deletions addon/components/linked-projects-table.hbs

This file was deleted.

33 changes: 33 additions & 0 deletions addon/components/linked-projects.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<LinkedModels
@models={{@projects}}
@modelName="project"
@removeLink={{@removeProject}}
@noDeleteButton={{true}} as |project|
>
<td
class={{
concat
"uk-table-shrink "
(if (eq @activeProject project.EPROID) "uk-text-bold")
}}
>
<LinkTo @route="project.form" @model={{project.EPROID}} class="uk-link">
{{project.EPROID}}
</LinkTo>
</td>
<td class={{if (eq @activeProject project.EPROID) "uk-text-bold"}}>
{{project.constructionProjectDescription}}
</td>
<td class="uk-table-shrink">
{{#if (eq @activeProject project.EPROID)}}
<button
type="button"
class="uk-icon-button"
uk-icon="trash"
uk-tooltip={{t "ember-gwr.components.linkedModels.removeLink"}}
{{on "click" @removeProject}}
>
</button>
{{/if}}
</td>
</LinkedModels>
11 changes: 11 additions & 0 deletions addon/components/project-form/checkbox.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="uk-width-1">
<input
type="checkbox"
class="uk-checkbox"
name={{@attr}}
required={{@required}}
checked={{@value}}
...attributes
{{on "input" this.update}}
/>
</div>
9 changes: 9 additions & 0 deletions addon/components/project-form/checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { action } from "@ember/object";
import Component from "@glimmer/component";

export default class ProjectFormCheckboxComponent extends Component {
@action
update(event) {
this.args.update(event.target.checked);
}
}
1 change: 1 addition & 0 deletions addon/components/project-form/field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@required={{@required}}
@value={{get @project @attr}}
@options={{@options}}
@noPlaceholder={{@noPlaceholder}}
@update={{fn (or @update this.updateProjectField) @attr}}
@translationBase={{@translationBase}}
disabled={{this.disableInput}}
Expand Down
8 changes: 5 additions & 3 deletions addon/components/project-form/select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
required={{@required}}
...attributes
>
<option value="">
{{t (concat @translationBase "." @attr "Placeholder")}}
</option>
{{#unless @noPlaceholder}}
<option value="">
{{t (concat @translationBase "." @attr "Placeholder")}}
</option>
{{/unless}}
{{#each @options as |optionValue|}}
<option selected={{eq optionValue @value}} value={{optionValue}}>
{{t (concat @translationBase "." @attr "Options." optionValue)}}
Expand Down
Loading

0 comments on commit 74fa404

Please sign in to comment.