Skip to content

Commit

Permalink
Merge pull request #5 from nswdpc/general-code-updates
Browse files Browse the repository at this point in the history
Updates and improvements
  • Loading branch information
tardinha authored Jun 2, 2023
2 parents f7382dc + 95281c4 commit bd46198
Show file tree
Hide file tree
Showing 8 changed files with 7,498 additions and 50 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ The object of this module is to:
+ allow editing and creation of links within the context of the parent record
+ ~~have no Javascript dependencies, beyond those provided by core framework fields~~ (we tried)
+ act as a drop-in replacement for the LinkField provided by [gorriecoe/silverstripe-linkfield](https://github.com/gorriecoe/silverstripe-linkfield) (NB: **for has-one relations only**)
+ **automatically publish** linked `File` and/or `SiteTree` relations when the parent record is published, via the Silverstripe ownership API


### Elemental inline editing
Expand Down
7,507 changes: 7,466 additions & 41 deletions client/package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/Forms/InlineLinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SilverStripe\Forms\OptionsetField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\Tip;
use SilverStripe\Forms\SelectionGroup;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectInterface;
Expand All @@ -30,12 +31,12 @@ class InlineLinkField extends CompositeField
{

/**
* @var gorriecoe\Link\Models\Link|null
* @var \gorriecoe\Link\Models\Link|null
*/
protected $record;

/**
* @var SilverStripe\ORM\DataObject|null
* @var \SilverStripe\ORM\DataObject|null
*/
protected $parent;

Expand Down Expand Up @@ -272,10 +273,12 @@ public function setSubmittedValue($values, $data = null)
$field->setSubmittedValue( $value );
}
}

return $this;
}

/**
* @param InlineLink_TitleField
* @param InlineLink_TitleField $field
*/
public function setTitleField(InlineLink_TitleField $field) {
$this->title_field = $field;
Expand All @@ -290,7 +293,7 @@ public function getTitleField() {
}

/**
* @param InlineLink_OpenInNewWindowField
* @param InlineLink_OpenInNewWindowField $field
*/
public function setOpenInNewWindowField(InlineLink_OpenInNewWindowField $field) {
$this->open_in_new_window_field = $field;
Expand All @@ -305,7 +308,7 @@ public function getOpenInNewWindowField() {
}

/**
* @param InlineLink_RemoveAction
* @param InlineLink_RemoveAction $field
*/
public function setRemoveField(InlineLink_RemoveAction $field) {
$this->remove_field = $field;
Expand Down Expand Up @@ -433,7 +436,6 @@ public function saveInto(DataObjectInterface $record)
/**
* Create or save a link using the value from the form field
* @param string $type eg. 'Email'
* @param mixed $value eg. '[email protected]'
* @param FormField $field the Form field holding the data related to the type
* @return Link
*/
Expand Down Expand Up @@ -585,7 +587,7 @@ public function prefixedFieldName($index) {
* @return string
*/
protected function getIndexFromName($complete_field_name) {
$type = "";
$index = "";
if($this->hasInlineElementalParent()) {
// the field name should start with the prefix...
if(strpos($complete_field_name, $this->getName() . self::FIELD_NAME_TYPE_SEPARATOR) !== 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/Forms/InlineLink_OpenInNewWindowField.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class InlineLink_OpenInNewWindowField extends CheckboxField {

use InlineLink;

/**
* @var string
*/
protected $link_type = '';

/**
* @inheritdoc
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Forms/InlineLink_RemoveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ class InlineLink_RemoveAction extends CheckboxField {

use InlineLink;

/**
* @var string
*/
protected $link_type = '';

}
2 changes: 2 additions & 0 deletions src/Forms/InlineLink_SiteTreeField.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace NSWDPC\InlineLinker;

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\TreeDropdownField;

class InlineLink_SiteTreeField extends TreeDropdownField {
Expand Down
7 changes: 6 additions & 1 deletion src/Forms/InlineLink_TitleField.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@

class InlineLink_TitleField extends TextField {

use InlineLink;

/**
* This is INPUT's type attribute value.
*
* @var string
*/
protected $inputType = 'text';

use InlineLink;
/**
* @var string
*/
protected $link_type = '';

public function Type()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Forms/InlineLink_TypeDefinedTextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class InlineLink_TypeDefinedTextField extends TextField {
*/
protected $inputType = 'text';

/**
* @var string
*/
protected $link_type = '';

public function Type()
{
return 'text';
Expand Down

0 comments on commit bd46198

Please sign in to comment.