Skip to content

Commit

Permalink
Merge pull request #494 from Neriderc/update-contextmenu
Browse files Browse the repository at this point in the history
Add option to highlight custom individuals
  • Loading branch information
Neriderc authored Jun 6, 2024
2 parents 956a9af + d557504 commit 9c6a128
Show file tree
Hide file tree
Showing 24 changed files with 902 additions and 102 deletions.
7 changes: 7 additions & 0 deletions app/FormSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ public function load($vars, $module): array
if (isset($vars["no_highlight_xref_list"]) && $this->isXrefListValid($vars["no_highlight_xref_list"])) {
$settings['no_highlight_xref_list'] = $vars["no_highlight_xref_list"];
}
$settings['highlight_custom_indis'] = isset($vars["highlight_custom_indis"]);
if (isset($vars["highlight_custom_col"]) && $this->isValidColourHex($vars["highlight_custom_col"])) {
$settings['highlight_custom_col'] = $vars["highlight_custom_col"];
}
if (isset($vars["highlight_custom"]) && $this->isXrefListValid($vars["highlight_custom"])) {
$settings['highlight_custom'] = $vars["highlight_custom"];
}
if (isset($vars["border_col"]) && $this->isValidColourHex($vars["border_col"])) {
$settings['border_col'] = $vars["border_col"];
}
Expand Down
4 changes: 3 additions & 1 deletion app/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate
}

// Get background colour
if ($this->isStartingIndividual($pid) && $this->dot->settings['highlight_start_indis'] == "true" && !$this->isValueInList($this->dot->settings['no_highlight_xref_list'], $pid)) {
if ($this->dot->settings['highlight_custom_indis'] && $this->isValueInList($this->dot->settings['highlight_custom'], $pid)) {
$indi_bg_colour = $this->dot->settings["highlight_custom_col"];
} else if ($this->isStartingIndividual($pid) && $this->dot->settings['highlight_start_indis'] == "true" && !$this->isValueInList($this->dot->settings['no_highlight_xref_list'], $pid)) {
$indi_bg_colour = $this->dot->settings["highlight_col"];
} else if ($this->dot->settings["sharednote_col_enable"] && $sharednotes->indiHasSharedNote($pid)) {
$indi_bg_colour = $sharednotes->getSharedNoteColour($pid);
Expand Down
2 changes: 1 addition & 1 deletion app/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(){
$this->defaultSettings['stripe_col_type_options'] = [self::OPTION_STRIPE_NONE => 'No stripe', self::OPTION_STRIPE_SEX_COLOUR => 'Based on individual's sex', self::OPTION_STRIPE_VITAL_COLOUR => 'Based on vital status', self::OPTION_STRIPE_AGE_COLOUR => 'Based on age'];
$this->defaultSettings['border_col_type_options'] = [self::OPTION_BORDER_CUSTOM_COLOUR => 'Custom', self::OPTION_BORDER_SEX_COLOUR => 'Based on individual's sex', self::OPTION_BORDER_FAMILY => 'Same as family border', self::OPTION_BORDER_VITAL_COLOUR => 'Based on vital status', self::OPTION_BORDER_AGE_COLOUR => 'Based on age'];
$this->defaultSettings['settings_sort_order_options'] = [0 => 'Oldest first', 10 => 'Newest first', 20 => 'Alphabetical order', 30 => 'Reverse alphabetical order'];
$this->defaultSettings['click_action_indi_options'] = [0 => 'Open individual\'s page', 10 => 'Add individual to list of starting individuals', 20 => 'Replace starting individuals with this individual', 30 => 'Add this individual to the list of stopping individuals', 40 => 'Replace stopping individuals with this individual', 50 => 'Show menu', 60 => 'Do nothing'];
$this->defaultSettings['click_action_indi_options'] = [0 => 'Open individual\'s page', 10 => 'Add individual to list of starting individuals', 20 => 'Replace starting individuals with this individual', 30 => 'Add this individual to the list of stopping individuals', 40 => 'Replace stopping individuals with this individual', 70 => 'Add to list of individuals to highlight', 50 => 'Show menu', 60 => 'Do nothing'];
$this->defaultSettings['countries'] = $this->getCountryAbbreviations();
if (!$this->isGraphvizAvailable($this->defaultSettings['graphviz_bin'])) {
$this->defaultSettings['graphviz_bin'] = "";
Expand Down
7 changes: 5 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@
'indi_background_age_low' => 0, // For background colour option for age, this is the age for the low colour - this age and anything younger gets the low colour
'indi_background_age_high' => 100, // For background colour option for age, this is the age for the high colour - this age and anything older gets this colour
'highlight_start_indis' => false, // Whether to use a different colour for starting individuals
'no_highlight_xref_list' => '', // XREFs in this list are not highlighted
'highlight_col' => '#FFFDC3', // Background of starting individuals
'no_highlight_xref_list' => '', // XREFs in this list are not highlighted when highlighting starting individuals
'highlight_col' => '#FFFDC3', // Background of starting individuals
'highlight_custom_indis' => '', // Whether to highlight a customer list of XREFs in addition to the about starting individuals
'highlight_custom_col' => '#FFFDC3', // The colour to highlight the custom highlighted individuals
'highlight_custom' => '', // List of XREFs of other individuals to highlight
'border_col' => '#606060', // Border colour (in UI this is Family border colour, but by default the individual border is the same as family)
'indi_border_col' => '#606060', // Border colour of individuals
'birth_prefix' => '*', // Text shown on chart before the birthdate
Expand Down
4 changes: 4 additions & 0 deletions resources/css/gvexport.css
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ span.NAME {
margin-left: 10px;
}

#highlight_custom {
width: calc(100% - 48px);
}

.align-middle-container {
display:flex;
align-items:center;
Expand Down
32 changes: 31 additions & 1 deletion resources/javascript/MainPage/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@
* @type {{}}
*/
const Form = {

/**
* Triggers on form change, to update diagram if autoUpdate enabled
*
* @param xref xref of tile we want to keep in the same position
*/
handleFormChange(xref = null) {
if (autoUpdate) {
// If xref has been nominated, calculate the position on screen, so we can keep it in the same place
if (xref) {
let [found, x, y] = UI.tile.getElementPositionFromXref(xref);
if (found) {
let scale = panzoomInst.getTransform().scale;
// Why is this 1 1/3 number needed?
let zoomBase = scale * (1 + 1/3);
let zoom_value = zoomBase * parseFloat(document.getElementById("dpi").value) / 72;
const rendering = document.getElementById('rendering');
const svg = rendering.getElementsByTagName('svg')[0];
let transform = panzoomInst.getTransform();
updateRender(x*zoom_value + transform.x, parseFloat(svg.getAttribute('height'))*zoomBase + y*zoom_value + transform.y, transform.scale, xref);
} else {
updateRender();
}
// Nothing fany happening, just update
} else {
updateRender();
}
}
},

/**
* Add or remove the % sign from the text input
*
Expand Down Expand Up @@ -484,7 +514,7 @@ const Form = {
}
listEl.value = indiList.join(',');
setTimeout(()=>{refreshIndisFromXREFS(false)}, 100);
handleFormChange();
Form.handleFormChange();
}
}
}
Expand Down
Loading

0 comments on commit 9c6a128

Please sign in to comment.