lundi 3 juillet 2023

How to make this CSS switch color background change in enabled / disabled sate?

I have a CSS switch like this:

* { box-sizing: border-box; }
.switch { appearance: none; padding: 9px 18px; border-radius: 13px; background: radial-gradient(circle 9px, #007722 100%, transparent 100%) transparent -9px; border: 1px solid #007722; }
.switch:checked { background-position: 9px; }
<input type="checkbox" class="switch"></div>

How to make that, disabled, it stays with a transparent background, but once enabled, it has another background?

Example:

enter image description here




Android Studio change checkbox result when changing language in app

I made an app where a user can check a box(checkbox). Also the app can be translated in 2 languages by code. How can I also make the result of the checkbox(true/false) to be translated when you change the language of the app?

I have not found something similar anywhere online.




dimanche 2 juillet 2023

Looker Studio Table with interactive Checkbox column

I'd like to create a Pipeline table that has a checkbox column which can be ticked in order to create a sum so you can instantly see what value from the Pipeline to commit to forecast. Hence, the table would need to be interactive.

The optimal solution would be that this sum can also be used as a metric, e.g. to deduct from the current Gap to target or to add to the current Bookings and divide by the target.

Does anyone know any solution that could accomplish this?

Honestly I have not tried anything specifically yet as I do not have a clue where to look at.

Thanks a lot and have a good weekend, Stefan




samedi 1 juillet 2023

Using flask_table to make a checkbox input column

The DonationTable class I am using to show data. In the derived DonationRegisterTable class I want to have a checkbox instead of a BoolCol so user can edit the table. Is there a way to have a checkbox as a column using flask_table?

from flask_table import Table, BoolCol, Col, ButtonCol


class DonationTable(Table):
    classes = ["table", "table-bordered"]

    id = Col("Id", show=False)
    account_id = Col("Account ID", show=False)
    month = Col("Month")
    year = Col("Year")
    paid = BoolCol("Paid")


class DonationRegisterTable(DonationTable):
    # I want this to be a checkbox
    paid = ButtonCol("Paid", "register_donation", url_kwargs=dict(account_id='account_id'))




jeudi 29 juin 2023

What is this element called? Two dimensional checkbox/radiobox?

I'm developing a Flutter app and I'm trying to find what this is called:

Thing I'm trying to find

Essentially, it's a checklist that only allows one input and is two dimensional.

Selection showed

In this image, the top left box is selected.

I'd appreciate any help in trying to find what this element is called.




mercredi 28 juin 2023

Automatically check/uncheck one checkbox if another is checked/unchecked in R Shiny

I have a Shiny app in which users may choose a number of textInput boxes based on a numericInput, which also determines the number of checkbox pairs. When these checkboxes are marked, the text in the textInput is added to separate lists depending on which checkbox is marked. In this app, everything that exists in the normalized_controls_coll list must also exist in the controls_coll list, but not necessarily vice versa. I have made an attempt at making it so that the normCTLcheckbox will automatically be checked if CTLcheckbox is checked, and that normCTLcheckbox will be unchecked if CTLcheckbox is unchecked.

Below is my best attempt, although this dependency does not happen. Does anyone have any ideas for this? Thanks!

library(shiny)
library(shinyWidgets)
library(htmlwidgets)

########## User interface ##########
ui = fluidPage(
  
  navbarPage("",
             
             #### Tab Panel 3 ####
             tabPanel("",
                      fluidRow(
                        sidebarPanel(
                          ####Conditions information####
                          #Determine the number of conditions to be labelled
                          
                          
                          numericInput("num_conds", 
                                       label = "Conditions",
                                       min = 1,
                                       max = 96,
                                       value = 1),
                          
                          br(),
                          h5(helpText("Changing the number of experimental conditions will erase all designated colors and conditions.")),
                          
                          helpText("control checkbox"),
                          verbatimTextOutput("ctls_checked"),
                          helpText('normalizing control checkbox'),
                          verbatimTextOutput("norm_ctls_checked")
                        ),
                        
                        mainPanel(
                          tags$style('.shiny-options-group{ 
                                        margin-top: 5px !important;}'),
                          
                          column(4, "",
                                 uiOutput("boxes_conds")
                          ), #close condition columns
                          
                          column(4, "",
                                 
                                 uiOutput("control_checkbox"),
                          ),
                          
                          
                        ),
                      ), #close fluidrow
             ), #End panel 3
  ) #close navbarpage
)#close ui, fluidpage


########## Server logic #########

server = function(input, output, session) {

  #### Page 3: Conditions ####
  
  #Number output for number of conditions
  output$value <- renderPrint({ input$num_conds })
  
  #Experimental condition boxes for UI text input
  output$boxes_conds <- renderUI({
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      cond_names <- textInput(paste0("condID", i),
                              label = paste0("Treatment/ Condition ", i),
                              placeholder = "Enter condition...")
    })
  })
  
  output$control_checkbox <- renderUI({
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      div(
        checkboxInput(paste0("CTLcheckbox", i), 
                      label = paste0("Control ", i), 
                      value = FALSE),
        
        checkboxInput(paste0("normCTLcheckbox", i), 
                      label = paste0("Normalizing control ", i), 
                      value = FALSE),
        
        
        style = 'padding-bottom: 7.62px;'

      )
    })
  })
  
  #verification list for the controls, positive/mut or negative/WT
  controls_list <- list()
  
  controls <- reactive({ 
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) { 
      if(input[[paste0('CTLcheckbox', i)]] ==  TRUE) 
        controls_list <- input[[paste0('condID', i)]]
    })
    
  })
  
  controls_coll <- reactive({ strsplit(paste0(unlist(controls(), recursive = FALSE), collapse = ','), ",") })
  
  output$ctls_checked <- renderPrint({ 
    controls_coll()
    
  })
  
  #verification list for the normalized controls list
  normalized_controls_list <- list()
  
  normalized_controls <- reactive({ 
    num_conds <- as.integer(input$num_conds)
    
    lapply(1:num_conds, function(i) {
      
      if(input[[paste0('normCTLcheckbox', i)]] ==  TRUE) 
        controls_list <- input[[paste0('condID', i)]]
    })
  })
  
  normalized_controls_coll <- reactive({ strsplit(paste0(unlist(normalized_controls(), recursive = FALSE), collapse = ','), ",") })
  
  
  output$norm_ctls_checked <- renderPrint({ 
    normalized_controls_coll()
    
  })

  #This is my current attempt at making it so that the normalized_control checkboxes are dependant on the control checkboxes
  observeEvent(input$num_conds, {
    lapply(1:input$num_conds, function(i){
      
      
      observeEvent(input[[paste0('CTLcheckbox', i)]], {
        #This will set the normalized_control checkboxes to FALSE whenever the control checkbox is FALSE
        if (input[[paste0('CTLcheckbox', i)]] == FALSE && input[[paste0('normCTLcheckbox', i)]] == TRUE)
          updateCheckboxInput(session, input[[paste0('normCTLcheckbox', i)]], value = input[[paste0('CTLcheckbox', i)]]) 
      })
      
      observeEvent(input[[paste0('normCTLcheckbox', i)]], {
        #This will update the control checkboxes to TRUE whenever the normalized_control checkbox is TRUE
        if (input[[paste0('CTLcheckbox', i)]] == FALSE && input[[paste0('normCTLcheckbox', i)]] == TRUE)
          updateCheckboxInput(session, input[[paste0('CTLcheckbox', i)]], value = input[[paste0('normCTLcheckbox', i)]]) 
      })
    })
  })
  
  
} # close server

shinyApp(ui = ui, server = server)



mardi 27 juin 2023

Custom checkbox validation error notice issue in Woocommerce registration

In WooCommerce, I am using the following code to add a custom "privacy" checkbox to the customer registration form:

// Addind a checkbox to registration form
add_action( 'woocommerce_register_form', 'add_privacy_checkbox_registration' );
function add_privacy_checkbox_registration() {
    $checkbox_text = sprintf( '%s <a href="%s"><strong>%s</strong></a>', __( 'Я прочитал и согласен с' ), 
    esc_url( site_url('/politic-conf/') ), __( 'политикой конфиденциальности' ) );
    ?>
    <div class="woocommerce-privacy-policy-wrapper">
        <p class="form-row validate-required">
            <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
            <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="privacy_policy" <?php checked( false, true ); ?> id="privacy-policy" />
                <span class="woocommerce-privacy-policy-checkbox-text"><?php echo $checkbox_text; ?></span> <abbr class="required" title="<?php esc_attr_e( 'required', 'woocommerce' ); ?>">*</abbr>
            </label>
            <input type="hidden" name="policy-field" value="1" />
        </p>
    </div>
    <?php
}

// The validation
add_filter( 'woocommerce_registration_errors', 'privacy_checkbox_registration_validation', 10, 3 );
function privacy_checkbox_registration_validation( $errors ) {
 
    if( is_checkout() ) {
        return $errors;
    }
 
    if ( empty( $_POST[ 'privacy_policy' ] ) ) {
        $errors->add( 'privacy_policy_reg_error', 'Вам нужно принять политику конфиденциальности.' );
    }
 
    return $errors;
 
}

The code works. The checkbox has been added. The checkbox logic works. That is, if you do not check the box, there will be no user registration.

But there is a problem. The error text is not displayed on the screen if the checkbox is not clicked...

Here is the page of my site with the problem - page with issue

Any ideas?