-
Notifications
You must be signed in to change notification settings - Fork 3
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 #9 from Vizzuality/feature/litigation-sides-edit
Feature/litigation sides edit
- Loading branch information
Showing
34 changed files
with
554 additions
and
47 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
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
ActiveAdmin.register Document do | ||
menu priority: 3 | ||
menu priority: 6 | ||
|
||
decorate_with DocumentDecorator | ||
|
||
|
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
ActiveAdmin.register Location do | ||
menu priority: 3 | ||
menu priority: 1 | ||
|
||
decorate_with LocationDecorator | ||
|
||
|
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
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,17 @@ | ||
@mixin tablet { | ||
@media (min-width: $breakpoint-tablet) { | ||
@content; | ||
} | ||
} | ||
|
||
@mixin desktop { | ||
@media (min-width: $breakpoint-desktop) { | ||
@content; | ||
} | ||
} | ||
|
||
@mixin desktop-large { | ||
@media (min-width: $breakpoint-desktop-large) { | ||
@content; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
class LitigationSideDecorator < Draper::Decorator | ||
delegate_all | ||
|
||
def name | ||
return h.link_to model.name, connected_entity_url if connected_entity.present? | ||
|
||
model.name | ||
end | ||
|
||
def party_type | ||
model.party_type&.humanize | ||
end | ||
|
||
def side_type | ||
model.side_type&.humanize | ||
end | ||
|
||
private | ||
|
||
def connected_entity_url | ||
return h.admin_company_path(connected_entity) if connected_entity.is_a?(Company) | ||
return h.admin_location_path(connected_entity) if connected_entity.is_a?(Location) | ||
end | ||
end |
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,44 @@ | ||
import { Controller } from 'stimulus'; | ||
|
||
const ENTITY_TYPE_PARTY_TYPE_MAP = { | ||
'Company': 'corporation', | ||
'Location': 'government' | ||
}; | ||
|
||
export default class extends Controller { | ||
connect() { | ||
$(this.connectedWithSelect).on('change', this._setDefaults.bind(this)); | ||
} | ||
|
||
_setDefaults() { | ||
if (this.connectedWithSelectedOption) { | ||
const entityType = this.connectedWithSelectedOption.value.split('-')[0]; | ||
const partyType = ENTITY_TYPE_PARTY_TYPE_MAP[entityType]; | ||
|
||
if (partyType) { | ||
$(this.partyTypeSelect).val(partyType); | ||
$(this.partyTypeSelect).trigger('change'); | ||
} | ||
|
||
this.nameInput.value = this.connectedWithSelectedOption.text; | ||
} | ||
} | ||
|
||
get connectedWithSelect () { | ||
return this.element.querySelector('select[id*="_connected_with"'); | ||
} | ||
|
||
get connectedWithSelectedOption () { | ||
return this.connectedWithSelect.selectedOptions && | ||
this.connectedWithSelect.selectedOptions.length && | ||
this.connectedWithSelect.selectedOptions[0]; | ||
} | ||
|
||
get nameInput() { | ||
return this.element.querySelector('input[id*="_name"'); | ||
} | ||
|
||
get partyTypeSelect() { | ||
return this.element.querySelector('select[id*="_party_type"'); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Controller } from 'stimulus'; | ||
|
||
export default class extends Controller { | ||
static targets = ['activeTab'] | ||
|
||
connect() { | ||
$(this.element).tabs(); | ||
|
||
$(this.element.querySelectorAll('.nav-tabs a')).on('click', (event) => { | ||
event.preventDefault(); | ||
this._changeActiveTabTo(event.target.hash); | ||
}); | ||
|
||
const activeTab = this.activeTabTarget.value; | ||
if (activeTab) { | ||
$(this.element).find(`.nav-tabs a[href="${activeTab}"]`).click(); | ||
} | ||
} | ||
|
||
_changeActiveTabTo(hash) { | ||
window.location.hash = hash; | ||
this.activeTabTarget.value = hash; | ||
} | ||
} |
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
Oops, something went wrong.