diff --git a/assets/css/_buttons.scss b/assets/css/_buttons.scss index 60dd7661c..f5c4ec48d 100644 --- a/assets/css/_buttons.scss +++ b/assets/css/_buttons.scss @@ -50,7 +50,7 @@ i { @extend .grey-text; font-size: 17px; display: inline-block; - margin-left: 10px; + margin-left: 10px; // TODO: the spacing should always be placed in the container, not in the content cursor: pointer; span { vertical-align: middle; diff --git a/assets/css/_card-modal.scss b/assets/css/_card-modal.scss index 9c546d5d1..8bbf58b20 100644 --- a/assets/css/_card-modal.scss +++ b/assets/css/_card-modal.scss @@ -74,49 +74,11 @@ li.collection-item { border: none; } - li.collection-item.download { - min-height: 6rem; - } - a.download { - @extend .grey-text; - position: relative; - > div { - padding-left: 70px; - max-width: 85%; - &:first-child { - background-color: #999999; - text-align: center; - border-radius: 50%; - height: 45px; - width: 45px; - padding-left: 0; - max-width: initial; - position: absolute; - top: 4px; - left: 5px; - i.material-icons { - @extend .white-text; - font-size: 1.5rem; - line-height: 45px; - } - } - p { - font-size: 1.1rem; - margin: 0.2rem 0; - } - } - &:after { - content: ""; - display: table; - clear: both; - zoom: 1; - } - .button { - background-color: color("grey", "darken-1"); - } - .button[disabled] { - border: 1px rgba(0, 0, 0, 0.1) solid; - background-color: transparent; + li.collection-item .file-section { + padding-left: 70px; + p { + font-size: 1.1rem; + margin: 0.2rem 0; } .title { @extend .black-text; @@ -132,9 +94,31 @@ width: fit-content; } } + a.download { + display: block; + text-align: center; + height: 45px; + width: 45px; + padding-left: 0; + max-width: initial; + i.material-icons { + @extend .black-text; + font-size: 1.5rem; + } + position: absolute; + top: 4px; + left: 5px; + &:after { + content: ""; + display: table; + clear: both; + zoom: 1; + } + } .access-link { padding: 0.5rem 0; - max-width: 85%; + display: flex; + align-items: center; .switch { display: inline-block; vertical-align: middle; @@ -179,6 +163,15 @@ } } } + .file-download { + display: flex; + align-items: center; + gap: 0.5rem; + + .btn-icon-grey { + margin-left: initial; + } + } div.link { @extend .grey-text; > div { diff --git a/assets/js/components/respondents/RespondentIndex.jsx b/assets/js/components/respondents/RespondentIndex.jsx index ebc16cb5d..6411d04df 100644 --- a/assets/js/components/respondents/RespondentIndex.jsx +++ b/assets/js/components/respondents/RespondentIndex.jsx @@ -58,7 +58,7 @@ type Props = { } type State = { - csvType: string, + shownFile: string, } class RespondentIndex extends Component { @@ -74,7 +74,7 @@ class RespondentIndex extends Component { constructor(props) { super(props) - this.state = { csvType: "" } + this.state = { shownFile: null } this.toggleResultsLink = this.toggleResultsLink.bind(this) this.toggleIncentivesLink = this.toggleIncentivesLink.bind(this) this.toggleInteractionsLink = this.toggleInteractionsLink.bind(this) @@ -249,7 +249,7 @@ class RespondentIndex extends Component { ) : ( @@ -260,7 +260,7 @@ class RespondentIndex extends Component { {link.url}
{!project.readOnly ? ( - + refresh @@ -317,8 +317,15 @@ class RespondentIndex extends Component { return numericFields.some((field) => field == filterField) } - downloadItem(id, itemType) { + toggleFile(fileId, event) { + event.preventDefault() + this.setState({ shownFile: this.state.shownFile == fileId ? null : fileId }) + } + + downloadItem(id) { const { t, totalCount, filter } = this.props + const { shownFile } = this.state + const currentFile = shownFile == id let item: ?{ title: String, description: String, @@ -407,41 +414,52 @@ class RespondentIndex extends Component { return null } else { const disabled = item.disabled - const titleDescription = ( -
-

- {item.title} -

-

{item.description}

- {disabled ?

{item.disabledText}

: null} + + const downloadButton = ( +
+ + + get_app + + + {t("Download last generated file")} + + { // (15 min ago + // FIXME: this should be calculated + } + + + refresh + + + { // ) + } +
) return (
  • - {itemType == "file" ? ( - { - if (disabled) return - e.preventDefault() - item && item.onDownload() - }} - > -
    - {disabled ? ( -
    - ) : ( - get_app - )} +
    + this.toggleFile(id, e)}> +
    + {currentFile ? "expand_more" : "chevron_right"} +
    +
    +
    +

    + {item.title} +

    +

    {item.description}

    + {disabled ?

    {item.disabledText}

    : null} + { currentFile ? +
    + { item.downloadLink } + { downloadButton }
    - {titleDescription} - - ) : ( -
    {titleDescription}
    - )} - {itemType == "link" ? item.downloadLink : null} + : "" + } +
  • ) } @@ -458,29 +476,22 @@ class RespondentIndex extends Component { return this.onFilterChange(value)} /> } - downloadModal({ itemType }) { + downloadModal() { const { userLevel, t, filter } = this.props const ownerOrAdmin = userLevel == "owner" || userLevel == "admin" - const [title, description] = - itemType == "file" - ? [t("Download CSV"), t("Choose the data you want to download")] - : [ - t("Public links"), - t("Choose the data you want to be able to access through a public link"), - ] return ( - +
    -
    {title}
    -

    {description}

    +
    {t("Download CSV")}
    +

    {t("Choose the data you want to download")}

      - {itemType == "file" && filter ? this.downloadItem("filtered-results", itemType) : null} - {this.downloadItem("results", itemType)} - {this.downloadItem("disposition-history", itemType)} - {ownerOrAdmin ? this.downloadItem("incentives", itemType) : null} - {ownerOrAdmin ? this.downloadItem("interactions", itemType) : null} + {filter ? this.downloadItem("filtered-results") : null} + {this.downloadItem("results")} + {this.downloadItem("disposition-history")} + {ownerOrAdmin ? this.downloadItem("incentives") : null} + {ownerOrAdmin ? this.downloadItem("interactions") : null}
    ) @@ -676,20 +687,8 @@ class RespondentIndex extends Component { __html: "", }} /> - - $(`#downloadCSV-${fileId}`).modal("open")} - /> - $(`#downloadCSV-${linkId}`).modal("open")} - /> - - {this.downloadModal({ itemType: fileId })} - {this.downloadModal({ itemType: linkId })} + $('#downloadCSV').modal("open")}/> + {this.downloadModal()} {this.renderColumnPickerModal()} {this.respondentsFilter()} <0>{{ names }} down<3>{\" \"} <5>": "Channels <1><0>{{ names }} down<3>{\" \"} <5>", "Checking this box will make the survey accept written numbers as valid numeric responses, like \"one\" or \"fifty five\". Written numbers are supported up to one hundred (100).": "", "Choose a key for each language": "", - "Choose the data you want to be able to access through a public link": "", "Choose the data you want to download": "", "Choose the disposition you want to set at this point of the questionnaire.": "", "Choose the questionnaire answers you want to use to define quotas": "", @@ -144,6 +143,8 @@ "Done": "", "Download CSV": "", "Download contents as CSV": "", + "Download file": "", + "Download last generated file": "", "Downloaded {{surveyName}} {{reportType}}": "", "Drop your CSV file here, or click to browse": "", "Drop your MP3, WAV, M4A, ACC or MP4 file here, or click to browse": "", @@ -344,8 +345,7 @@ "Project successfully unarchived": "", "Projects": "", "Provider": "", - "Public link:": "", - "Public links": "", + "Public link": "", "QUEUE SIZE": "", "Quantity": "", "Question Prompt": "", @@ -372,6 +372,7 @@ "Ready to launch_survey": "", "Record": "", "Refused": "", + "Regenerate file": "", "Registered": "", "Rejected": "", "Remove collaborator": "",