示例#1
0
文件: view.hpp 项目: lyase/vidanueva
 WebView(pModel model, Wt::WContainerWidget* parent=nullptr) : Wt::WTemplate(parent) {
     setTemplateText(tr("page-view"));
     if (model) {
         bindString("title", model->title);
         bindString("body", model->body);
     }
 }
示例#2
0
文件: AuthWidget.C 项目: 913862627/wt
void AuthWidget::createLoginView()
{
  setTemplateText(tr("Wt.Auth.template.login"));

  createPasswordLoginView();
  createOAuthLoginView();
}
 DialogButtonBar(WDialog& dialog) : MoreAwesomeTemplate(dialog.contents()) {
     setTemplateText(tr("dialog-button-bar"));
     bindAndCreateWidget(_okBtn, "ok-btn", tr("ok-btn"));
     bindAndCreateWidget(_cancelBtn, "cancel-btn", tr("cancel-btn"));
     _okBtn->clicked().connect(&dialog, &WDialog::accept);
     _cancelBtn->clicked().connect(&dialog, &WDialog::reject);
 }
示例#4
0
 /**
 * @brief Gives you a nice pair of buttons
 *
 * @param parent Parent Widget
 */
 ButtonBar(const WString& button1Text="", const WString& button2Text="", WContainerWidget* parent=0) : MoreAwesomeTemplate(parent) {
     WString btn1Text = button1Text.empty() ? WString::tr("OK") : button1Text;
     WString btn2Text = button2Text.empty() ? WString::tr("Cancel") : button2Text;
     setTemplateText(tr("button-bar"));
     setStyleClass("yui-gb button-bar");
     bindAndCreateWidget(_btn1, "btn-1", btn1Text);
     bindAndCreateWidget(_btn2, "btn-2", btn2Text);
 }
示例#5
0
WTemplate::WTemplate(const WString& text, WContainerWidget *parent)
  : WInteractWidget(parent),
    previouslyRendered_(0),
    newlyRendered_(0),
    encodeInternalPaths_(false),
    changed_(false)
{
  setInline(false);
  setTemplateText(text);
}
示例#6
0
RegistrationView::RegistrationView(Session& session,
				   Wt::Auth::AuthWidget *authWidget)
  : Wt::Auth::RegistrationWidget(authWidget),
    session_(session)
{
  setTemplateText(tr("template.registration"));
  detailsModel_ = new UserDetailsModel(session_, this);

  updateView(detailsModel_);
}
示例#7
0
文件: AuthWidget.C 项目: 913862627/wt
void AuthWidget::createLoggedInView()
{
  setTemplateText(tr("Wt.Auth.template.logged-in"));

  bindString("user-name", login_.user().identity(Identity::LoginName));  

  WPushButton *logout = new WPushButton(tr("Wt.Auth.logout"));
  logout->clicked().connect(this, &AuthWidget::logout);

  bindWidget("logout", logout);
}
示例#8
0
/* ****************************************************************************
 * Edit Users
 */
EditUsers::EditUsers(Wt::Dbo::Session& aSession, const std::string& basePath) : session_(aSession), basePath_(basePath)
{
    setStyleClass("user-editor");
    setTemplateText(tr("edit-users-list"));
    limitEdit_  = new Wt::WLineEdit;
    Wt::WPushButton* goLimit = new Wt::WPushButton(tr("go-limit"));
    goLimit->clicked().connect(SLOT(this, EditUsers::LimitList));
    bindWidget("limit-edit",limitEdit_);
    bindWidget("limit-button",goLimit);
    LimitList();
} // end EditUsers::EditUsers
示例#9
0
WTemplate::WTemplate(const WString& text, WContainerWidget *parent)
  : WInteractWidget(parent),
    previouslyRendered_(0),
    newlyRendered_(0),
    encodeInternalPaths_(false),
    encodeTemplateText_(true),
    changed_(false),
    widgetIdMode_(SetNoWidgetId)
{
  plainTextNewLineEscStream_ = new EscapeOStream();
  plainTextNewLineEscStream_->pushEscape(EscapeOStream::PlainTextNewLines);
  setInline(false);
  setTemplateText(text);
}
示例#10
0
LoginWindow::LoginWindow(WContainerWidget* parent) : MoreAwesomeTemplate(parent) {
    setTemplateText(tr("login-template"));
    addStyleClass("yui-gd dialog form"); // 1/3 + 2/3 style
    bindAndCreateField(_usernameLabel, _usernameEdit, "username");

    // Password
    bindAndCreateField(_passwordLabel, _passwordEdit, "password");
    _passwordEdit->setEchoMode(WLineEdit::Password);

    // Buttons
    bindWidget("btn-bar", _btnBar = new ButtonBar(tr("Login"), tr("Cancel")));
    _btnBar->btn1()->clicked().connect(this, &LoginWindow::handleOKHit);
    _btnBar->btn2()->clicked().connect(this, &LoginWindow::handleCancelHit);

    // Hook up accept and reject signals
    // All these do an accept
    _passwordEdit->enterPressed().connect(this, &LoginWindow::handleOKHit);    

    // These do reject
    _usernameEdit->escapePressed().connect(this, &LoginWindow::handleCancelHit);
    _passwordEdit->escapePressed().connect(this, &LoginWindow::handleCancelHit);
}
示例#11
0
ShareCreatePassword::ShareCreatePassword()
{
	auto model = std::make_shared<ShareCreatePasswordFormModel>();

	setTemplateText(tr("template-share-create-password"));
	addFunction("id", &WTemplate::Functions::id);
	addFunction("block", &WTemplate::Functions::id);

	// Password
	auto password = std::make_unique<Wt::WLineEdit>();
	password->setEchoMode(Wt::EchoMode::Password);
	setFormWidget(ShareCreatePasswordFormModel::PasswordField, std::move(password));

	// Buttons
	Wt::WPushButton* unlockBtn = bindNew<Wt::WPushButton>("unlock-btn", tr("msg-unlock"));
	unlockBtn->clicked().connect([=]
	{
		updateModel(model.get());

		if (model->validate())
		{
			FS_LOG(UI, DEBUG) << "Create password validation OK";

			success().emit();
			return;
		}

		FS_LOG(UI, DEBUG) << "Create password validation failed";

		// Mitigate brute force attemps
		sleep(1);

		updateView(model.get());
	});

	updateView(model.get());
}
示例#12
0
    // inline constructor
    UserFormView() {
        model_ = new UserFormModel(this);

        setTemplateText(tr("userForm-template"));
        addFunction("id", &WTemplate::Functions::id);

        /*
	 * First Name
	 */
	setFormWidget(UserFormModel::FirstNameField, new Wt::WLineEdit());

	/*
	 * Last Name
	 */
	setFormWidget(UserFormModel::LastNameField, new Wt::WLineEdit());

	/*
	 * Country
	 */
	Wt::WComboBox *countryCB = new Wt::WComboBox();
	countryCB->setModel(model_->countryModel());

	countryCB->activated().connect(std::bind([=] () {
	    std::string code = model_->countryCode(countryCB->currentIndex());
	    model_->updateCityModel(code);
	}));

	setFormWidget(UserFormModel::CountryField, countryCB,
            [=] () { // updateViewValue()
	        std::string code = boost::any_cast<std::string>
		    (model_->value(UserFormModel::CountryField));
		int row = model_->countryModelRow(code);
		countryCB->setCurrentIndex(row);
	    },

            [=] () { // updateModelValue()
	        std::string code = model_->countryCode(countryCB->currentIndex());
		model_->setValue(UserFormModel::CountryField, code);
            });

	/*
	 * City
	 */
	Wt::WComboBox *cityCB = new Wt::WComboBox();
	cityCB->setModel(model_->cityModel());
	setFormWidget(UserFormModel::CityField, cityCB);

	/*
	 * Birth Date
	 */
	Wt::WLineEdit *dateEdit = new Wt::WLineEdit();
	Wt::WDatePicker *birthDP = new Wt::WDatePicker(dateEdit);
	bindWidget("birth-dp", birthDP);

	setFormWidget(UserFormModel::BirthField, dateEdit,
	    [=] () { // updateViewValue()
	        Wt::WDate date = boost::any_cast<Wt::WDate>
		    (model_->value(UserFormModel::BirthField));
                birthDP->setDate(date);
	    }, 

            [=] () { // updateModelValue()
	        Wt::WDate date = birthDP->date();
                model_->setValue(UserFormModel::BirthField, date);
	    });

        /*
	 * Children
	 */ 
	setFormWidget(UserFormModel::ChildrenField, new Wt::WSpinBox());

	/*
	 * Remarks
	 */
	Wt::WTextArea *remarksTA = new Wt::WTextArea();
	remarksTA->setColumns(40);
	remarksTA->setRows(5);
	setFormWidget(UserFormModel::RemarksField, remarksTA);

	/*
	 * Title & Buttons
	 */
        Wt::WString title = Wt::WString("Create new user");
        bindString("title", title);

        Wt::WPushButton *button = new Wt::WPushButton("Save");
        bindWidget("submit-button", button);

        bindString("submit-info", Wt::WString());

        button->clicked().connect(this, &UserFormView::process);

        updateView(model_);
    }
示例#13
0
void SpinBoxField::_setTemplate(){
	setTemplateText(Wt::WString::tr("field"));
}
示例#14
0
    // inline constructor
    UserFormView() {
        model = std::make_shared<UserFormModel>();

        setTemplateText(tr("userForm-template"));
        addFunction("id", &WTemplate::Functions::id);
        addFunction("block", &WTemplate::Functions::id);

        /*
	 * First Name
	 */
	setFormWidget(UserFormModel::FirstNameField,
	              Wt::cpp14::make_unique<Wt::WLineEdit>());

	/*
	 * Last Name
	 */
	setFormWidget(UserFormModel::LastNameField,
	              Wt::cpp14::make_unique<Wt::WLineEdit>());

	/*
	 * Country
	 */
	auto countryCB = Wt::cpp14::make_unique<Wt::WComboBox>();
	auto countryCB_ = countryCB.get();
	countryCB->setModel(model->countryModel());

	countryCB_->activated().connect([=] {
	    std::string code = model->countryCode(countryCB_->currentIndex());
	    model->updateCityModel(code);
	});

        setFormWidget(UserFormModel::CountryField, std::move(countryCB),
            [=] { // updateViewValue()
                std::string code =
                    Wt::asString(model->value(UserFormModel::CountryField)).toUTF8();
		int row = model->countryModelRow(code);
		countryCB_->setCurrentIndex(row);
	    },

            [=] { // updateModelValue()
                std::string code = model->countryCode(countryCB_->currentIndex());
		model->setValue(UserFormModel::CountryField, code);
            });

	/*
	 * City
	 */
	auto cityCB = Wt::cpp14::make_unique<Wt::WComboBox>();
	cityCB->setModel(model->cityModel());
	setFormWidget(UserFormModel::CityField, std::move(cityCB));

	/*
	 * Birth Date
	 */
	auto dateEdit = Wt::cpp14::make_unique<Wt::WDateEdit>();
	auto dateEdit_ = dateEdit.get();
	setFormWidget(UserFormModel::BirthField, std::move(dateEdit),
	    [=] { // updateViewValue()
	        Wt::WDate date = Wt::cpp17::any_cast<Wt::WDate>
		    (model->value(UserFormModel::BirthField));
		dateEdit_->setDate(date);
	    }, 

            [=] { // updateModelValue()
                Wt::WDate date = dateEdit_->date();
                model->setValue(UserFormModel::BirthField, date);
	    });

        /*
	 * Children
	 */ 
	setFormWidget(UserFormModel::ChildrenField, Wt::cpp14::make_unique<Wt::WSpinBox>());

	/*
	 * Remarks
	 */
	auto remarksTA = Wt::cpp14::make_unique<Wt::WTextArea>();
	remarksTA->setColumns(40);
	remarksTA->setRows(5);
	setFormWidget(UserFormModel::RemarksField, std::move(remarksTA));

	/*
	 * Title & Buttons
	 */
	Wt::WString title = Wt::WString("Create new user");
        bindString("title", title);

        auto button = Wt::cpp14::make_unique<Wt::WPushButton>("Save");
        auto button_ = bindWidget("submit-button", std::move(button));

        bindString("submit-info", Wt::WString());

        button_->clicked().connect(this, &UserFormView::process);

        updateView(model.get());
    }