-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HP-2320: add logic for type
and move_type
input when move
#182
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace hipanel\modules\stock\widgets; | ||
|
||
use yii\base\InvalidConfigException; | ||
use yii\helpers\ArrayHelper; | ||
use yii\helpers\Html; | ||
use yii\widgets\InputWidget; | ||
|
||
class MoveTypeDropDownList extends InputWidget | ||
{ | ||
public array $items = []; | ||
|
||
public function init(): void | ||
{ | ||
parent::init(); | ||
if (!$this->hasModel()) { | ||
throw new InvalidConfigException("Model is required"); | ||
} | ||
$id = ArrayHelper::getValue($this->options, 'id'); | ||
$this->view->registerJs(/** @lang JavaScript */ <<<JS | ||
(($) => { | ||
"use strict"; | ||
$("#$id").val(""); | ||
const dstSelect = $("#$id").parents(".box").find("select[id*=\"-dst_id\"]"); | ||
if (dstSelect.length) { | ||
dstSelect.on("change", function () { | ||
const dstType = $(this).find("option:selected").data("type"); | ||
if (["chwbox", "stock"].includes(dstType)) { | ||
$("#$id").val("stock"); | ||
} else if ([ | ||
"ahcloud", | ||
"avdsnode", | ||
"cloudstorage", | ||
"delivery", | ||
"dedicated", | ||
"system", | ||
"nic", | ||
"cdnstat", | ||
"remote", | ||
"reserved", | ||
"suspended", | ||
"termination", | ||
"utilization", | ||
"unused", | ||
"cdnv2", | ||
"vdsmaster", | ||
"cloudservers", | ||
].includes(dstType)) { | ||
$("#$id").val("install"); | ||
} else { | ||
$("#$id").val(""); | ||
} | ||
}); | ||
} | ||
})(jQuery); | ||
JS | ||
); | ||
} | ||
|
||
public function run() | ||
{ | ||
return Html::activeDropDownList($this->model, $this->attribute, $this->items, ArrayHelper::merge($this->options, ['prompt' => ''])); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
PHP 8.0 function used but PHP 7.3 installations are supported
The core package
hipanel-core
supports PHP ^7.3||^8.0, butstr_contains()
is only available in PHP 8.0+. This could cause runtime errors in PHP 7.3 environments.Suggestions:
strpos() !== false
as a PHP 7.3 compatible alternative🔗 Analysis chain
Conditional for RMA combos is appropriate.
Using
str_contains
requires at least PHP 8.0. Verify the minimum PHP version in composer.json or project config to avoid runtime errors on older PHP versions.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 18
Script:
Length of output: 135
Script:
Length of output: 3712
Script:
Length of output: 3882