Added Placeholder to ChoiceSet (#4811)
* Fixed the crash issue * Fixed Bleeding Crash Issue * finishing up changes for bleed update * work in progress * updated ChoiceSetInput.cpp * ios change * schema & uwp changes * Updated specs * Android Changes * addressed review comments * Updated specs * Added placeholder text example to test cards * added a new card * added UWP test images * Fixed bad merge * updated schema * Updated specs Co-authored-by: Adaptive Cards Specs CI <donotreply@microsoft.com> Co-authored-by: almedina-ms <35784165+almedina-ms@users.noreply.github.com> Co-authored-by: shalinijoshi19 <shalinij@microsoft.com>
This commit is contained in:
Родитель
39a2362b60
Коммит
d8a889b88f
|
@ -11,6 +11,7 @@
|
|||
"label": "Required Input.ChoiceSet label (compact)",
|
||||
"isRequired": true,
|
||||
"errorMessage": "This is a required input",
|
||||
"placeholder" : "Please make selection",
|
||||
"choices": [
|
||||
{
|
||||
"title": "Option 1",
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "AdaptiveCard",
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"version": "1.3",
|
||||
"body": [
|
||||
{
|
||||
"type": "Input.ChoiceSet",
|
||||
"id": "CompactSelectVal",
|
||||
"label": "What color do you want? (compact)",
|
||||
"style": "compact",
|
||||
"isRequired": true,
|
||||
"errorMessage": "This is a required input",
|
||||
"placeholder": "Please choose",
|
||||
"choices": [
|
||||
{
|
||||
"title": "Red",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"title": "Green",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"title": "Blue",
|
||||
"value": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "Action.Submit",
|
||||
"title": "OK"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -20,10 +20,14 @@
|
|||
"type": "string",
|
||||
"description": "The initial choice (or set of choices) that should be selected. For multi-select, specify a comma-separated string of values."
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string",
|
||||
"description": "Description of the input desired. Only visible when no selection has been made, the `style` is `compact` and `isMultiSelect` is `false`"
|
||||
},
|
||||
"wrap": {
|
||||
"type": "boolean",
|
||||
"description": "If `true`, allow text to wrap. Otherwise, text is clipped.",
|
||||
"version": "1.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14790,6 +14790,48 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_ChoiceSetInput_1GetPlaceholder(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
|
||||
jstring jresult = 0 ;
|
||||
AdaptiveCards::ChoiceSetInput *arg1 = (AdaptiveCards::ChoiceSetInput *) 0 ;
|
||||
std::shared_ptr< AdaptiveCards::ChoiceSetInput const > *smartarg1 = 0 ;
|
||||
std::string result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
(void)jarg1_;
|
||||
|
||||
smartarg1 = *(std::shared_ptr< const AdaptiveCards::ChoiceSetInput > **)&jarg1;
|
||||
arg1 = (AdaptiveCards::ChoiceSetInput *)(smartarg1 ? smartarg1->get() : 0);
|
||||
result = ((AdaptiveCards::ChoiceSetInput const *)arg1)->GetPlaceholder();
|
||||
jresult = jenv->NewStringUTF((&result)->c_str());
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_ChoiceSetInput_1SetPlaceholder(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
|
||||
AdaptiveCards::ChoiceSetInput *arg1 = (AdaptiveCards::ChoiceSetInput *) 0 ;
|
||||
std::string *arg2 = 0 ;
|
||||
std::shared_ptr< AdaptiveCards::ChoiceSetInput > *smartarg1 = 0 ;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
(void)jarg1_;
|
||||
|
||||
smartarg1 = *(std::shared_ptr< AdaptiveCards::ChoiceSetInput > **)&jarg1;
|
||||
arg1 = (AdaptiveCards::ChoiceSetInput *)(smartarg1 ? smartarg1->get() : 0);
|
||||
if(!jarg2) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return ;
|
||||
}
|
||||
const char *arg2_pstr = (const char *)jenv->GetStringUTFChars(jarg2, 0);
|
||||
if (!arg2_pstr) return ;
|
||||
std::string arg2_str(arg2_pstr);
|
||||
arg2 = &arg2_str;
|
||||
jenv->ReleaseStringUTFChars(jarg2, arg2_pstr);
|
||||
(arg1)->SetPlaceholder((std::string const &)*arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_ChoiceSetInput_1dynamic_1cast(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
|
||||
jlong jresult = 0 ;
|
||||
AdaptiveCards::BaseCardElement *arg1 = (AdaptiveCards::BaseCardElement *) 0 ;
|
||||
|
|
|
@ -675,6 +675,8 @@ public class AdaptiveCardObjectModelJNI {
|
|||
public final static native void ChoiceSetInput_SetValue(long jarg1, ChoiceSetInput jarg1_, String jarg2);
|
||||
public final static native boolean ChoiceSetInput_GetWrap(long jarg1, ChoiceSetInput jarg1_);
|
||||
public final static native void ChoiceSetInput_SetWrap(long jarg1, ChoiceSetInput jarg1_, boolean jarg2);
|
||||
public final static native String ChoiceSetInput_GetPlaceholder(long jarg1, ChoiceSetInput jarg1_);
|
||||
public final static native void ChoiceSetInput_SetPlaceholder(long jarg1, ChoiceSetInput jarg1_, String jarg2);
|
||||
public final static native long ChoiceSetInput_dynamic_cast(long jarg1, BaseCardElement jarg1_);
|
||||
public final static native long new_ChoiceSetInputParser__SWIG_0();
|
||||
public final static native long new_ChoiceSetInputParser__SWIG_1(long jarg1, ChoiceSetInputParser jarg1_);
|
||||
|
|
|
@ -91,6 +91,14 @@ public class ChoiceSetInput extends BaseInputElement {
|
|||
AdaptiveCardObjectModelJNI.ChoiceSetInput_SetWrap(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public String GetPlaceholder() {
|
||||
return AdaptiveCardObjectModelJNI.ChoiceSetInput_GetPlaceholder(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void SetPlaceholder(String value) {
|
||||
AdaptiveCardObjectModelJNI.ChoiceSetInput_SetPlaceholder(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public static ChoiceSetInput dynamic_cast(BaseCardElement baseCardElement) {
|
||||
long cPtr = AdaptiveCardObjectModelJNI.ChoiceSetInput_dynamic_cast(BaseCardElement.getCPtr(baseCardElement), baseCardElement);
|
||||
return (cPtr == 0) ? null : new ChoiceSetInput(cPtr, true);
|
||||
|
|
|
@ -240,7 +240,7 @@ public class ChoiceSetInputRenderer extends BaseCardElementRenderer
|
|||
boolean hasEmptyDefault = value.isEmpty();
|
||||
if (hasEmptyDefault)
|
||||
{
|
||||
titleList.addElement("");
|
||||
titleList.addElement(choiceSetInput.GetPlaceholder());
|
||||
selection = (int)size;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ static NSString *pickerCell = @"pickerCell";
|
|||
_rootView = rootView;
|
||||
_delegate = (NSObject<UITableViewDelegate> *)_dataSource;
|
||||
_showPickerView = NO;
|
||||
_defaultString = @"";
|
||||
_defaultString = [NSString stringWithCString:choiceSet->GetPlaceholder().c_str() encoding:NSUTF8StringEncoding];
|
||||
|
||||
NSBundle *bundle = [NSBundle bundleWithIdentifier:@"MSFT.AdaptiveCards"];
|
||||
[bundle loadNibNamed:@"ACRPickerView" owner:rootView options:nil];
|
||||
|
|
|
@ -95,6 +95,7 @@ void ChoiceSetInput::SetWrap(bool value)
|
|||
{
|
||||
m_wrap = value;
|
||||
}
|
||||
|
||||
std::string ChoiceSetInput::GetPlaceholder() const
|
||||
{
|
||||
return m_placeholder;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"HostConfigHash":null,"CardHash":"7707e16","Error":null}
|
Двоичные данные
source/uwp/AdaptiveCardTestApp/Expected/Fixed Size Non-Interactive.v1.3.Elements.Input.ChoiceSet.Placeholder.png
Normal file
Двоичные данные
source/uwp/AdaptiveCardTestApp/Expected/Fixed Size Non-Interactive.v1.3.Elements.Input.ChoiceSet.Placeholder.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 720 B |
|
@ -0,0 +1 @@
|
|||
{"HostConfigHash":null,"CardHash":"7707e16","Error":null}
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.5 KiB |
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "AdaptiveCard",
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"version": "1.3",
|
||||
"body": [
|
||||
{
|
||||
"type": "Input.ChoiceSet",
|
||||
"id": "CompactSelectVal",
|
||||
"label": "What color do you want? (compact)",
|
||||
"style": "compact",
|
||||
"isRequired": true,
|
||||
"errorMessage": "This is a required input",
|
||||
"placeholder": "Please choose",
|
||||
"choices": [
|
||||
{
|
||||
"title": "Red",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"title": "Green",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"title": "Blue",
|
||||
"value": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "Action.Submit",
|
||||
"title": "OK"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"HostConfigHash":"569178d","CardHash":"7707e16","Error":null}
|
Двоичные данные
source/uwp/AdaptiveCardTestApp/Expected/testVariantHostConfig.v1.3.Elements.Input.ChoiceSet.Placeholder.png
Normal file
Двоичные данные
source/uwp/AdaptiveCardTestApp/Expected/testVariantHostConfig.v1.3.Elements.Input.ChoiceSet.Placeholder.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.0 KiB |
|
@ -0,0 +1 @@
|
|||
{"actions":[{"title":"OK","type":"Action.Submit"}],"body":[{"choices":[{"title":"Red","value":"1"},{"title":"Green","value":"2"},{"title":"Blue","value":"3"}],"errorMessage":"This is a required input","id":"CompactSelectVal","isRequired":true,"label":"What color do you want? (compact)","style":"Compact","type":"Input.ChoiceSet"}],"type":"AdaptiveCard","version":"1.3"}
|
|
@ -733,6 +733,7 @@ AdaptiveNamespaceStart
|
|||
|
||||
String Value;
|
||||
Boolean IsMultiSelect;
|
||||
String Placeholder;
|
||||
Boolean Wrap;
|
||||
ChoiceSetStyle ChoiceSetStyle;
|
||||
Windows.Foundation.Collections.IVector<AdaptiveChoiceInput> Choices { get; };
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace AdaptiveNamespace
|
|||
m_wrap = sharedChoiceSetInput->GetWrap();
|
||||
m_choiceSetStyle = static_cast<ABI::AdaptiveNamespace::ChoiceSetStyle>(sharedChoiceSetInput->GetChoiceSetStyle());
|
||||
RETURN_IF_FAILED(UTF8ToHString(sharedChoiceSetInput->GetValue(), m_value.GetAddressOf()));
|
||||
RETURN_IF_FAILED(UTF8ToHString(sharedChoiceSetInput->GetPlaceholder(), m_placeholder.GetAddressOf()));
|
||||
|
||||
InitializeBaseElement(std::static_pointer_cast<BaseInputElement>(sharedChoiceSetInput));
|
||||
return S_OK;
|
||||
|
@ -62,6 +63,13 @@ namespace AdaptiveNamespace
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT AdaptiveChoiceSetInput::get_Placeholder(_Outptr_ HSTRING* placeholder)
|
||||
{
|
||||
return m_placeholder.CopyTo(placeholder);
|
||||
}
|
||||
|
||||
HRESULT AdaptiveChoiceSetInput::put_Placeholder(_In_ HSTRING placeholder) { return m_placeholder.Set(placeholder); }
|
||||
|
||||
HRESULT AdaptiveChoiceSetInput::get_Wrap(_Out_ boolean* wrap)
|
||||
{
|
||||
*wrap = m_wrap;
|
||||
|
@ -121,6 +129,7 @@ namespace AdaptiveNamespace
|
|||
choiceSet->SetIsMultiSelect(m_isMultiSelect);
|
||||
choiceSet->SetValue(HStringToUTF8(m_value.Get()));
|
||||
choiceSet->SetWrap(m_wrap);
|
||||
choiceSet->SetPlaceholder(HStringToUTF8(m_placeholder.Get()));
|
||||
|
||||
RETURN_IF_FAILED(GenerateSharedChoices(m_choices.Get(), choiceSet->GetChoices()));
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace AdaptiveNamespace
|
|||
HRESULT RuntimeClassInitialize(const std::shared_ptr<AdaptiveSharedNamespace::ChoiceSetInput>& sharedChoiceSetInput);
|
||||
|
||||
// IAdaptiveChoiceSetInput
|
||||
IFACEMETHODIMP get_Placeholder(_Outptr_ HSTRING* placeholder);
|
||||
IFACEMETHODIMP put_Placeholder(_In_ HSTRING placeholder);
|
||||
|
||||
IFACEMETHODIMP get_Value(_Outptr_ HSTRING* value);
|
||||
IFACEMETHODIMP put_Value(_In_ HSTRING value);
|
||||
|
@ -160,6 +162,7 @@ namespace AdaptiveNamespace
|
|||
boolean m_isMultiSelect;
|
||||
ABI::AdaptiveNamespace::ChoiceSetStyle m_choiceSetStyle;
|
||||
Microsoft::WRL::Wrappers::HString m_value;
|
||||
Microsoft::WRL::Wrappers::HString m_placeholder;
|
||||
};
|
||||
|
||||
ActivatableClass(AdaptiveChoiceSetInput);
|
||||
|
|
|
@ -107,6 +107,12 @@ namespace AdaptiveNamespace
|
|||
XamlHelpers::CreateXamlClass<IComboBox>(HStringReference(RuntimeClass_Windows_UI_Xaml_Controls_ComboBox));
|
||||
|
||||
|
||||
HString placeHolderText;
|
||||
ComPtr<IComboBox2> comboBox2;
|
||||
RETURN_IF_FAILED(comboBox.As(&comboBox2));
|
||||
RETURN_IF_FAILED(adaptiveChoiceSetInput->get_Placeholder(placeHolderText.GetAddressOf()));
|
||||
RETURN_IF_FAILED(comboBox2->put_PlaceholderText(placeHolderText.Get()));
|
||||
|
||||
// Set HorizontalAlignment to Stretch (defaults to Left for combo boxes)
|
||||
ComPtr<IFrameworkElement> comboBoxAsFrameworkElement;
|
||||
RETURN_IF_FAILED(comboBox.As(&comboBoxAsFrameworkElement));
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
| **isMultiSelect** | `boolean` | No | Allow multiple choices to be selected. | 1.0 |
|
||||
| **style** | `ChoiceInputStyle` | No | | 1.0 |
|
||||
| **value** | `string` | No | The initial choice (or set of choices) that should be selected. For multi-select, specify a comma-separated string of values. | 1.0 |
|
||||
| **placeholder** | `string` | No | Description of the input desired. Only visible when no selection has been made, the `style` is `compact` and `isMultiSelect` is `false` | 1.0 |
|
||||
| **wrap** | `boolean` | No | If `true`, allow text to wrap. Otherwise, text is clipped. | 1.2 |
|
||||
|
||||
**Inherited properties**
|
||||
|
|
Загрузка…
Ссылка в новой задаче